Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL-Doesn't return a value when the columns are multiplied

I have 3 columns in my db table, I need to multiply column, itm_count & itm_price and output the total for a given id(itm_id).

SELECT sum(itm_price * itm_count) as total FROM ods_temporder WHERE itm_id='11'

I tried to do this using the above sql query, but the result was null. What seems to be the issue here?

like image 703
pier Avatar asked May 14 '26 07:05

pier


1 Answers

What do this give you?

SELECT itm_price, itm_count FROM ods_temporder WHERE itm_id='11'

Is either of itm_price or itm_count NULL? Do you have rows for itm_id = 11?

like image 58
gbn Avatar answered May 15 '26 21:05

gbn