SQL Question, Aggregate and nonAggregate fields..
Posted in 1998
Topics: SQL Development & Query Writing
SQL Question Aggregate and non-aggregate fields. I have the table dtv_articles... Article_id (unique primary key integer) series_id (integer) publish_date date etc... I want the article_id that would be the latest article for each group of series... If I do select max(publish_date), series_id from dtv_articles group by series_id order by series_id; I get exactly what I want, but not the article_id. If I add: select max(publish_date), series_id, article_id from dtv_articles group by series_id order by series_id; I have to group by article_id, which no longer gives me the max(publish_date) per series, but per series and article_id... How do I get the fields that are not part of the groups??? Thanks -John -- John B. Windberg Database Administrator Imagine Media Inc. jonwa@imaginemedia.com