Questions tagged [ifnull]

This tag refers to the process of determining whether or not a particular object is null, and then running certain code based off of that condition.

Use this tag for questions related to running certain code depending on whether or not one or more objects is null.

161 questions
0
votes
3 answers

MySQL SELECT IFNULL then compare it numerically with other column

I've tried numerous methods to translate NULL to the number 0 upon selection: SELECT ss.id AS staff_id, u.realname AS realname, ss.amount AS salary_amount, IF(s.paid_amount IS NOT NULL, s.paid_amount,0.00) AS paid_amount, …
Jeebsion
  • 343
  • 2
  • 3
  • 10
0
votes
1 answer

sqlite update left join two tables

I have 2 tables that i join with LEFT JOIN function tableA & tableB - data1,col1 and data2,col2 are the references column I use to match both tables entries - data3 is a number I use to sum with value from TableB.col3 - data4 is the value I want to…
joe
  • 103
  • 3
  • 10
0
votes
3 answers

Query not returning anything when no last_name value found

I just built this new conditional query for pulling either a first_name AND last_name OR company_name based on the display_as value: Select If(`display_as` = 'individual', CONCAT(first_name, ' ', last_name) ,`company_name`) as name FROM…
Joe Shmoe
  • 27
  • 5
0
votes
0 answers

Using IFNULL() when no data returned

We have a MySQL DB that is consolidated from two other MySQL DB's. This consolidation takes place every morning at about 5am. When the consolidation task fails, I can see it easily enough with: select * from progress_log where stoptime =…
MrrMan
  • 158
  • 1
  • 13
0
votes
3 answers

How to convert ifnull statement in tableau to powerbi dax?

I'm working on a dashboard conversion from tableau to power bi.Stuck with a calculated dimension in tableau that is needed to be converted to powerbi using dax! By Replacing the IFNULL statement in tableau. I've tried the ISBLANK parameter in dax…
0
votes
0 answers

MYSQL Result set differs when adding concatenation

I am trying to find a logical answer to an issue I'm having with two different results sets in MYSQL. When I do concatenation on the list of table 3 fields into a single column, I get a different number of results. I don't know if this matters, but…
ComputersAreNeat
  • 175
  • 1
  • 1
  • 11
0
votes
1 answer

MySQL IFNULL is not returning result

I am trying to fetch remaining quantity of books with following approach stock = total+(receive-Issued); Table book_qnt - lists of book Quantiy id | book | qnt ======================= 1 | 1 | 20 2 | 2 | 12 …
Hemant
  • 83
  • 3
  • 9
0
votes
2 answers

Why ifnull() return DECIMAL instead of BIGINT in MariaDB 10.1+?

Why ifnull() return DECIMAL instead of BIGINT in MariaDB 10.1? For example: Query: select a, ifnull(b, 1) from table; 10.0.22-MariaDB: ifnull(b, 1) type is BIGINT 10.1.37-MariaDB: ifnull(b, 1) type is DECIMAL Moreover, in both versions the return…
Songe
  • 39
  • 1
  • 8
0
votes
1 answer

Snowflake: IFNULL can not be used in the subSQL of INSERT VALUES

Got the compilation error when tried to use the IFNULL in the INSERT VALUES clause. SQL: INSERT INTO widgets VALUES (12, (select ifnull(max(c), 0)+1 from DCSN_Testing where c = 1), 444) Error: SQL compilation error: Invalid expression [(SELECT…
Brian Z
  • 99
  • 1
  • 9
0
votes
1 answer

Microsoft Access: Adding Text box, Combo box and a way where if no entry is put in, it will still run

I have been working on a project as a volunteer crime analyst, and I have run into issues on how to enter in multiple text boxes, a multi-valued combo box and how to make sure that if there are no entries made that those boxes are ignored in favor…
NMats
  • 15
  • 5
0
votes
2 answers

SQL query to return specific labels if exist (0 if it does not exist)

There are two tables given, tag and media. mysql> select * from media; +----+---------+----------+ | id | name | duration | +----+---------+----------+ | 1 | cat.mp4 | 3.4 | | 2 | dog.mp4 | 8 | +----+---------+----------+ mysql>…
0
votes
1 answer

select value if exists or default from another table

I have a table of user preferences - 'pr_gantt_config' and a table of default values for all the configurable elements of the chart - 'pr_gantt'. I was hoping this query would return either the user expressed the preference or the default value from…
0
votes
1 answer

Calculate using join between two tables for cases where joined table has no match

I'm trying to calculate values (subtract B from A) between a static and a dynamic table. In some cases the dynamic table won't yet have records matching the static table so I just want it to subtract 0. My Join is returning NULLs in these cases…
user3649739
  • 1,829
  • 2
  • 18
  • 28
0
votes
2 answers

using ifnull with index creation in mysql

I am trying to create an index in MySQL whereas the query will first check what column is not null. After checking, it will create the index on the column that is not null. However, I am not successful in creating this and it says I have an error,…
coldhands
  • 327
  • 1
  • 3
  • 13
0
votes
2 answers

Counting between dates

I need the count of all dates including the nonexistent SELECT ifnull(COUNT(*),0) as num , date_format(c.dataCupo,"%d/%m/%Y") as data FROM cupons c WHERE c.dataCupo between "2017-02-02" AND "2018-05-04" AND c.proveidor!="VINCULADO" and…