Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Please Help With SQL

Re: Please Help With SQL

From: Richard Kuhler <noone_at_nowhere.com>
Date: Tue, 12 Mar 2002 23:05:48 GMT
Message-ID: <gRvj8.21976$Gu6.8943597@typhoon.san.rr.com>


select max(bandname), yearproduced, max(title), min(title) from bands, albums
where (albums.bandid, albums.yearproduced) in (   select bandid, yearproduced
  from albums
  group by bandid, yearproduced
  having count(*) = 2
  )
  and albums.bandid = bands.bandid
group by albums.bandid, yearproduced

Richard Kuhler

Alison Pont wrote:
>
> Table Bands with columns:
> BandId, BandName
>
> Table Albums with columns:
> AId, BandId, Title, YearProduced
>
> How do find all bands that recorded TWO albums in the same year? I want to
> output BandName and the names of each of two albums (the Tiltles) in the
> same record.
>
> eg.
> BandName Title Title YearProduced
> ----------------------------------------------------------
> Bread BestHits1 BestHits2 1982
> James Last Classic1 Classics2 1988
>
> Thanks in advance.
Received on Tue Mar 12 2002 - 17:05:48 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US