difficult query

Поиск
Список
Период
Сортировка
Искать
От
Jakub Ouhrabka
Тема
difficult query
Дата
в 10:00:20
Msg-id
Pine.LNX.4.33.0205041559440.17441-100000@u-pl2
Список
Дерево обсуждения
difficult query Jakub Ouhrabka <jouh8664@ss1000.ms.mff.cuni.cz>
Re: difficult query Ian Barwick <barwick@gmx.net>
Hi,

I'd like to ask how to write sql query returning following results without
using any other table than table1 (e.g. without outer join with table
containing all possible day numbers...)

table1:
day  |  data
------------
1    |  x
1    |  x
2    |  x
4    |  x
4    |  x


I'd like to write query returning this:

query results:
day | number of records for a day
----------------------
1   |  2
2   |  1
3   |  0   <--- !!!
4   |  2

Is it possible to do this in sql?

thanks a lot,          kuba



В списке pgsql-sql по дате отправления
От: Tom Lane
Дата:
От: Ian Barwick
Дата:
Сообщение: Re: difficult query
FAQ