I'm having trouble figuring out how to select something.
This is the problem:

>From a copy of the CDDB-database i want to select the artist & album that
has on average the longest tracks.

But in the tracks table there is no such field as length, so i have to
calculate it. But when i try to do so it just gives me errors.

This is the erroneous query i have made so far

select albums.ARTIST, albums.TITLE from tracks,albums
where tracks.DISCID = albums.DISCID
group by tracks.DISCID
having(albums.LENGTH/count(tracks.TRACK)) = 
(
  select max(albums.LENGTH/count(tracks.TRACK)) from tracks,albums
  where tracks.DISCID = albums.DISCID
  group by tracks.DISCID
);

What is the correct way of selecting the album?
-- 
Dennis K.
~..   It is impossible to make anything foolproof,
.>>.  because fools are so ingenious -Roger Berg-
 |\



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html


Reply via email to