Complex query question

Поиск
Список
Период
Сортировка
От Mike Orr
Тема Complex query question
Дата
Msg-id CAH9f=uo+hF+FkGbu9Nta3Z_Q=Jrx8L68ryj6UT7uAeBKVxac+w@mail.gmail.com
обсуждение исходный текст
Ответы Re: Complex query question
Re: Complex query question
Список pgsql-general
I have a complex query question whose answer I think would help me to
understand subselects and aggregates better. I have a table with four
columns of interest:

id (int primary key), loc_title (varchar null), loc_value (float
null), loc_unit (varchar null)

I want the output columns to be:
(1) each distinct value of loc_title, sorted
(2) an id of a record containing that loc_title
(3) the loc_value for the record in column 2
(4) the loc_unit for the record in column 2

I don't care as much how the records for columns 2-4 are chosen. It
could be max(loc_value), min(id), or something else. I just need some
sample records to test my program against.

Is this something I should be able to do with a single query with a
subselect, or is it too much for one query? I tried a few ways and
none of them were syntactically valid.

--
Mike Orr <sluggoster@gmail.com>

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

Предыдущее
От: "David Johnston"
Дата:
Сообщение: Re: Deleting one of 2 identical records
Следующее
От: Thom Brown
Дата:
Сообщение: Re: Deleting one of 2 identical records