|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Show '0' on a summary
Hi!
I have a db with a table of articles and a table with a cashflow register that consists of article, count and total sum (among other things) Table: article nr, name, price 1, phone, 500 2, table, 400 3, toy, 100 4, t-shirt, 200 Table: cashflow nr, article, count, sum 1, 2, 1, 400 2, 2, 2, 800 3, 1, 1, 500 4, 4, 4, 600 5, 4, 1, 200 What I want is to get a report that sums up whats been sold. I know howto write the report but I cant get that '0' to show. 1, phone, 500 2, table, 1200 3, toy, 0 4, t-shirt, 800 I've tried with "IFNULL(sum(cashflow.sum), '0'), but it didnt work. Any help much appreciated! /Hylsan |
|
#2
|
|||
|
|||
|
Can you show us your query?
|
|
#3
|
|||
|
|||
|
Quote:
hum something like this; Code:
select cashflow.article, article.name, sum(cashflow.sum) as sum from cashflow inner join article on cashflow.article = article.nr where date between '2009-01-01' and '2009-01-31'; dont really have the code here but something like this. /Hylsan |
|
#4
|
||||
|
||||
|
Code:
SELECT article.nr
, article.name
, sum(cashflow.sum) AS sum
FROM article
LEFT OUTER
JOIN cashflow
ON cashflow.article = article.nr
WHERE article.date BETWEEN '2009-01-01' AND '2009-01-31'
GROUP
BY article.nr
![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Show '0' on a summary |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|