Skip to content

Instantly share code, notes, and snippets.

@baybatu
Last active August 19, 2016 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baybatu/2f71d89236936ed65290cac1be2afc29 to your computer and use it in GitHub Desktop.
Save baybatu/2f71d89236936ed65290cac1be2afc29 to your computer and use it in GitHub Desktop.
PL/SQL'de MIN fonksiyonuyla null yerine bir değer dönmek
SELECT
  MIN(NVL(t.column, 0))
FROM TABLE t
WHERE t.OTHERTABLE_ID = 1234
      AND t.Condition = 1;

Eğer Condition koşulunu sağlayan herhangi bir satır bulunamazsa bu durumda MIN fonksiyonu null döner. Bunu engellemek için MIN'i NVL ile sarmak faydalı olabilir.

SELECT
  NVL(MIN(NVL(t.column, 0)), 0)
FROM TABLE t
WHERE t.OTHERTABLE_ID = 1234
      AND t.Condition = 1;

Bu durumda ön tanımlı değer olarak 0 döner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment