Questions tagged [isnull]

`ISNULL` is a proprietary SQL function that replaces NULL with the specified replacement value.

ISNULL is a SQL function that replaces NULL with the specified replacement value.

The ANSI/ISO SQL standard function COALESCE serves the same purpose, and is widely implemented.

Reference

MSDN Article

706 questions
3
votes
2 answers

( CASE WHEN [date] IS NULL THEN 0 ELSE 1 END) is not working in my pivot

I have written the follwoing code expecting to get 0's and 1's returned in the CASES but I get 1's and NULL's. any suggestions to get 0's? DECLARE @Today DATETIME SET @Today = FLOOR(CAST(GETDATE() AS FLOAT)) SELECT* FROM ( SELECT…
BramW
  • 31
  • 3
3
votes
5 answers

SQL Server NULL value with inner join

I am using C# and SQL Server. Take a look at the following SQL: SELECT table1.id, table1.description, table2.name, table2.surname FROM table1 INNER JOIN table2 ON table1.EmpID = table2.EmpID It is straight forward and works fine. It retrieves…
Yash
  • 2,259
  • 4
  • 26
  • 33
3
votes
1 answer

Replace NULL with 0 in Pivot Table combined with avg CAST

I'm trying to replace NULL to 0 in the output of my TagValue column combined with avg Cast. I tried the following query: ISNULL(TRY_CAST(TagValue AS DECIMAL(18,2)),0) AS TagValue in the code DECLARE @cols AS NVARCHAR(MAX), @query AS…
Zohar Shani
  • 41
  • 1
  • 2
3
votes
1 answer

Pandas keep 'null' and ' ' when loading CSV

I have a weird CSV that has "null" as a value, as well it has an empty cell as a value. So my row looks like this: null,0,0,0,1,,,,0,0,0,null I'm doing nothing but reading and rewriting a file: f = pd.read_csv(input_file,sep=',', quotechar='"',…
Balkyto
  • 1,460
  • 4
  • 22
  • 47
3
votes
2 answers

Oracle ORA-01722: invalid number Error because of WHERE IS NULL Condition

I have the following SQL: Select MyNumber FROM (SELECT to_number(Name) AS MyNumber FROM TableA WHERE regexp_replace(Name, '\d+') IS NULL) The Query is supposed to filter out non-numeric Names from TableA by checking if nothing is left, if…
Xardestro
  • 31
  • 1
  • 2
3
votes
1 answer

NoSuchMethodError: The getter 'length' was called on null

So currently I'm building apps with Flutter which's still new to me, and I'm stuck at that exception in that title. The problem is when I tried to call "widget.usernames.length" at ListView.builder, it would return that exception if it's null and no…
Faris Azam
  • 41
  • 1
  • 1
  • 5
3
votes
5 answers

How does Scala handle isnull or ifnull in query with sqlContext

I have two data files as below: course.txt id,course 1,Hadoop 2,Spark 3,HBase 5,Impala Fee.txt id,amount 2,3900 3,4200 4,2900 I need to list all course info with their fee: sqlContext.sql("select c.id, c.course, f.amount from course c left…
Choix
  • 555
  • 1
  • 12
  • 28
3
votes
2 answers

ISNULL(value, 0) in WHERE clause MYSQL

I have this requets: SELECT sc.no, scl.quantite, scl.description, scl.poids, scl.prix, sl_ref.refsl, sl_ref.codetva, sl_ref.tauxtva, sl_ref.compte FROM shop_commande AS sc, shop_commande_ligne AS scl, selectline_ref AS sl_ref WHERE sc.id =…
Maloz
  • 165
  • 1
  • 2
  • 17
3
votes
4 answers

IsNull() sql function

I am attempting increment the value of a column field named "Number" by 1, and if the value is currently Null I would like to set the value to 1 because a Null value cannot be incremented. I discovered the isNull() function and do not get the…
D0uble0
  • 175
  • 1
  • 2
  • 12
3
votes
2 answers

Select statement with in ISNULL

I am writing a stored procedure and within this procedure I am using isNULL. If the value is null I want to use a select statement as the replacement value is this even possible? IF ISNULL(@v_FilePrefix, (SELECT @v_FilePrefix = TransactionTypePrefix…
Tempname
  • 565
  • 5
  • 26
3
votes
2 answers

Sql ISNULL condition in Sql Pivot and Sql case

I searched for many solutions on SO and elsewhere but couldn't quite understand how to write a query for my problem. Anyway my query looks like below SELECT * FROM ( SELECT Id, Date, Name, Amount, CASE WHEN…
3
votes
1 answer

Subquery in ISNULL,IIF,CASE statements

Subquery that is give as a parameter in ISNULL or IIF or CASE gets executed irrespective of the condition To explain what I mean, consider the below example. When I run the below query and look in the execution plan, I find that even if the variable…
mkr
  • 115
  • 1
  • 4
  • 12
3
votes
4 answers

How to write IsNullOrEmpty method similar to ISNULL in sql server

I want to have function in sql server similar to ISNULL() except it should check expression for null and empty also. If first parameter is null or empty, returns second. can someone help me?
vishal
  • 596
  • 2
  • 12
  • 31
3
votes
1 answer

How to select in PostgreSQL table where an attribute is not NULL?

I have this PostgreSQL table, test: a | b | c | d ---+---+---+--- 5 | | 5 | 7 5 | 6 | | 1 | 2 | 3 | I want to query all tuples whose b value is not NULL: SELECT * FROM test WHERE b != NULL; SELECT * FROM test WHERE b <> NULL; The two…
Kingston Chan
  • 923
  • 2
  • 8
  • 25
3
votes
3 answers

SQL Server : ISNULL(compound NULL condition, 'a string') returns only the 1st character, under certain circumstance(s)

I'm a self-taught, vaguely competent SQL user. For a view that I'm writing, I'm trying to develop a 'conditional LEFT' string-splitting command (presumably later to be joined by a 'conditional RIGHT' - whereby: If a string (let's call it…
underscore_d
  • 6,309
  • 3
  • 38
  • 64