Re: max and sum function

Поиск
Список
Период
Сортировка
От ryanne cruz
Тема Re: max and sum function
Дата
Msg-id 1048391256.3e7d2e58a80b9@mail.up.edu.ph
обсуждение исходный текст
Список pgsql-php
hi list.

does anyone here knows of a function that is similar to the sum function but
involves more than one column? for example, i have a table with columns id,
col1, col2 and col3. i want to get the max value from the three columns gruped
by an id.

what i came up with is something like this:

max1=select max(one) from (select sum(col1) as one from table group by id);
max2=select max(two) from (select sum(col2) as two from table group by id);
max3=select max(three) from (select sum(col3) as three from table group by
id);

then i compare the 3 max values and get the maximum of the 3.

is there an easier way to do this?

thanks.

ryanne



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

Предыдущее
От: "David Busby"
Дата:
Сообщение: Re: volunteer/peer review request
Следующее
От: Ahmad Sentri
Дата:
Сообщение: test