Agregate Problem?
| От | Len Morgan |
|---|---|
| Тема | Agregate Problem? |
| Дата | |
| Msg-id | 000501bee726$b7aa08e0$0908a8c0@H233.bstx.com обсуждение |
| Ответы |
Re: [SQL] Agregate Problem?
|
| Список | pgsql-sql |
I am having a problem with queries that have an aggregate (sum in this case) when no rows meet my criteria. I still get back a row with null values for all fields. Is this the correct behavior? I am trying to sum up daily sales quanties by items and if I don't have any sales on a particular day, I want to print nothing. I thought I could do this by detecting a 0 row count but since I have the aggregates, I still 1 row. Example: SELECT itemno,sum(qty) FROM sales WHERE sale_date = 'now()::date' I would expect to get back zero rows if there were no sales today but I get back 1. Of course I also get back 1 row if I only sold 1 item. Is this a bug or a "feature?" Thanks Len Morgan
В списке pgsql-sql по дате отправления: