Re: Is this possible in Oracle SQL?

From: A D Kendall <nobody_at_nowhere.com>
Date: 2000/06/01
Message-ID: <8h5rv1$ro1$1_at_supernews.com>#1/1


[Quoted] Thanks a lot, thats certainly got me looking in the right direction, but I won't know how many "ANALYSIS_CODES" there are. In my example I used two (A and B) but there could be any number.
[Quoted] For example, if there are 5 records in the detail table where ANALYSIS_CODE [Quoted] = A,B,C,D,E and F, then I need five columns in the results. (Ideally I would [Quoted] like the columns to be named A,B,C,D,E and F (i.e. whatever data was in the [Quoted] ANALYSIS_CODE field) but that's probably another problem!

Tereschenko I.V. <igor_v_t_at_mail.ru> wrote in message news:39365D1D.80616006_at_mail.ru...
> Hi, Andrew !
>
> I believe you need a query like this:
>
> select main.dat, first.anal_total, second.anal_total, main.total
> from head main,
> (select anal_total, id from det where ANLAYSIS_CODE='A') first,
> (select anal_total, id from det where ANLAYSIS_CODE='B') second
> where main.id=first.id and main.id=second.id;
>
> I assume that
> HEAD is a header table
> DET is a detail table
> DAT is a date column
>
> A D Kendall wrote:
>
> > I wonder if anyone can help with this SQL syntax problem...
> >
> > I have 2 tables linked by "ID" as follows:
> >
> > Header Table Detail Table
> >
> > ID DATE TOTAL ID ANLAYSIS_CODE ANAL_TOTAL
>

Received on Thu Jun 01 2000 - 00:00:00 CEST

Original text of this message