Re: Sorting data based fields in two linked tables

From: Oliver d'Azevedo Christina <oliveiros(dot)cristina(at)gmail(dot)com>
To: "R(dot) Smith" <ship(dot)quotes(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Sorting data based fields in two linked tables
Date: 2011-05-14 12:58:54
Message-ID: 578F5EAE-5567-4254-AE34-380B249E8F63@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Can you provide An example?

Best,
Oliveiros

Enviado via iPhone

Em 13/05/2011, às 04:00 PM, "R. Smith" <ship(dot)quotes(at)gmail(dot)com> escreveu:

> 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
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Charlie 2011-05-14 13:54:10 Re: [SQL] Sorting data based fields in two linked tables
Previous Message R. Smith 2011-05-13 15:00:16 Sorting data based fields in two linked tables