Sorting data based fields in two linked tables

Поиск
Список
Период
Сортировка
От R. Smith
Тема Sorting data based fields in two linked tables
Дата
Msg-id BANLkTikak22Fgv=jQ0DmiNf8yAB_nb3xgg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Sorting data based fields in two linked tables  (Oliver d'Azevedo Christina <oliveiros.cristina@gmail.com>)
Список pgsql-sql
Hi,

I am looking for a way to sort data returned from two tables with the
first sort based on a field from table A and the secord sort based on
the results of the first sort but the sort field is from table B.
While I can sort on either fields from either table, I cannot get it
to work on both. I have tried a crosstab query, but this a fails as
the number of rows returned from TABLE B for each row in TABLE A is an
unknown. I tried creating a temporary table, to then sort on, but this
failed as well. Example layout below:

Table A

ID FIELD1 FIELD2

Table B

ID, A.ID FIELD1,FIELD2

Output Based on sorting A.FIELD2, then B.FIELD1

A.ID,A.FIELD1,A.FIELD2,  B.FIELD1,B.FIELD2, B.FIELD1,B.FIELD2, B.FIELD1,B.FIELD2

Can anyone help me with this?

Regards


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

Предыдущее
От: Samuel Gendler
Дата:
Сообщение: Re: ordering by date for each ID
Следующее
От: Oliver d'Azevedo Christina
Дата:
Сообщение: Re: Sorting data based fields in two linked tables