Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query

Author  Topic 

ani07in
Starting Member

5 Posts

Posted - 2005-10-26 : 02:06:19
i have a table with following records

id is auto increment field
issueid is a numeric field


id issueid Body
1 1 my tite
2 2 Testing
3 1 titile1
4 3 titile2
5 4 titile3
6 3 titile5
7 5 titile9
8 1 titile8
9 2 titile7
10 5 titile11



the above table is for Forums where people can discuss there queries
new issueid is generated for every new forum and issueid for the forum will be same for the replies posted for a particular forum.



how will i retreive the fields for the first post of any thread....

the result for the above table should be

id issueid Body
1 1 my tite
2 2 Testing
4 3 titile2
5 4 titile3
7 5 titile9


Thanx in advance

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-26 : 02:23:18
Try this

Select T1.* from yourTable T1 inner join
(
select min(id) as id,issueid from yourTable group by issueid
) T2
on T1.id=T2.id where T1.issueid=T2.issueid


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -