Please help me with SQL! 
Author Message
 Please help me with SQL!

Look up the SQL statemnts SELECT DISTINCT and GROUP BY.


> Hi all,

> I am fighting hard to finish a sql query. I am not an expert on SQL so
> I appreciate your great help -

> I have a table called article. I want to display the author for every
> article under the same section but has the lastest post date. I wrote
> the sql this way -
> select author_name, most_recent_date
> from ( select max(post_date) as most_recent_date, section_id from
> article group by section_id ) a left join article b on
> a.most_recent_date=b.post_date and a.section_id = b.section_id

> It works fine but produces duplicate results. The reason is that each
> article entry is indentified by article_id but I can not put this
> field into the aggreation selection. I only need one row per section,
> but the result is mulitple rows per section displayed if happendly two
> or more articles have the same post_date and section_id fields..

> How to write this query? Thanks a lot!!

Wed, 09 Feb 2005 04:06:35 GMT
 [ 1 post ] 

 Relevant Pages 

1. Please help restore database SQL 6.5 to SQL 2000

2. Please help restore database SQL 6.5 to SQL 2000

3. Please help restore database SQL 6.5 to SQL 2000

4. PLEASE HELP - connecting to SQL Server

5. Please Help.....Access Vs Sql Server Referential Integrity

6. Sombody please help me with SQL server 2000 basic issue

7. Please help with dynamic sql query

8. PLEASE help with a SQL query

9. Please help me with SQL Mail

10. PLEASE HELP with dynamic SQL!

11. please help with simple SQL query

Powered by phpBB® Forum Software