| От | Scara Maccai |
|---|---|
| Тема | return MAX and when it happened |
| Дата | |
| Msg-id | 4924271D.1080407@yahoo.it обсуждение исходный текст |
| Ответы |
Re: return MAX and when it happened
Re: return MAX and when it happened |
| Список | pgsql-general |
Hi all,
suppose I have a table like:
CREATE TABLE mytab
(
num integer,
mydate timestamp
);
and I want to find MAX(num) and the "mydate" where it first happened.
I guess I could use
select * from mytab where num = (select MAX(num) from mytab) order by
mydate limit 1;
but that would scan the data twice (I guess...)
Do I have to write my own MAX function, something like:
select MYMAX(num, timestamp) from mytab
which would return a custom type?
Or is there a better way?
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера