grouping query results

Поиск
Список
Период
Сортировка
От Joolz
Тема grouping query results
Дата
Msg-id 36567.10.0.4.254.1109584103.squirrel@webmail.arbodienst-limburg.nl
обсуждение исходный текст
Ответы Re: grouping query results  (Andrew McMillan <andrew@catalyst.net.nz>)
Re: grouping query results  (Mitch Pirtle <mitch.pirtle@gmail.com>)
Re: grouping query results  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-php
Hello everyone,

In a PHP / Postgresql application I have to make a lot of lists like
this:

THE DATA STRUCTURE
employee_number, employee_name, department

THE OUTPUT
------------------------------------
employee_number  employee_name

department X
1                Johnson
22               Jackson
subtotal: 2 employees

department Y
222              Smith
3                Doe
44               Jameson
subtotal: 3 employees

grand total: 5 employees
------------------------------------

I see 2 ways to solve this:

- use SELECT for the detail lines and SELECT COUNT (*) for the (sub)
  totals

- SELECT the whole lot and let PHP do the grouping and counting

The second solution seems old fashioned to me and the first has a
catch: all queries have to be made within a single transaction.

I have the feeling that this is a very common question, how do you
people handle it? I looked at a lot of script sites, but no luck.

Thanks for any ideas / feedback!


В списке pgsql-php по дате отправления:

Предыдущее
От: Zouari Fourat
Дата:
Сообщение: Re: is it a bug or is it my mistake ?
Следующее
От: Zouari Fourat
Дата:
Сообщение: Re: is it a bug or is it my mistake ?