i would like to get result max(timenum) per setid,insertid
in my case it is (ps. i dont want to add identity column)
prjnum setid insertid timenum top_m
vb1---------- -------- ----------- ------------------------ ----------------
--
52 1 1 20 NULL 0.57599998
52 2 1 20 NULL 0.57599998
52 2 2 20 NULL 0.57599998
52 3 1 30 NULL 0.1584
52 3 3 50 NULL 0.29519999
select * from table A WHERE A.prjnum = 52 and A.vb1 is not null and
A.timenum
= (select max(timenum) as timenum from table B where A.setid = b.setid
and A.insertid = b.insertid and B.prjnum = 52 and B.vb1 is not null )
Praveen Maddali
MCDBA
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
You can use the following statement:
select T1.* from table as T1
where T1.timenum=(select max(timenum) from table as T2 where
T1.setid=T2.setid and T1.insertid=T2.insertid)
and T1.prjnum = 52 and T1.vb1 is not null
order by T1.setid,T1.insertid
This posting is provided "AS IS" with no warranties, and confers no rights.
Best Regards,
Gui-Dong Xiao
Microsoft Support
1. select nested select question
I got stuck on the following select command:
select * from club c full outer join member m on c.club= m.club;
--this is working
but
select t.club from (select * from club c full outer join member m on
c.club=m.club ) as t;
--error:
SQL0203N A reference to column "T.CLUB" is ambiguous. SQLSTATE=42702
and if change to
select t.club from (select t.club from club....) as t;
-- this is working too
Any tip?
Thanks lots
--
John Wu
Toronto
2. Unattended SQL Server 6.0 Installation- Success/Failure?
3. ??? SQL SELECT Question ???
8. SQL*LOADER and SEQUENCE values
11. select question