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)
 A simple logical problem ... Can u solve please

Author  Topic 

nssjari
Starting Member

46 Posts

Posted - 2005-06-27 : 02:34:28
SQl

select
csd_orig, csd_subj, csd_type, csd_numb, csd_revi
from
e0362csd
where
csd_subj='SIBP' and csd_type='D' and csd_numb='0002'

Results

CSD_ORIG, CSD_SUBJ, CSD_TYPE, CSD_NUMB, CSD_REVI
BS , SIBP , D , 0002 , 0
BS , SIBP , D , 0002 , 1
BS , SIBP , D , 0002 , 2

Out of this records I need to display only a record with last revision '2'

May I know how do i do that ... with the above query ...
Please do reply as soon as possible ... Thanks in advance

Jari
Computer Engg

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-06-27 : 02:50:22
select
csd_orig, csd_subj, csd_type, csd_numb, MAX(csd_revi)
from
e0362csd
where
csd_subj='SIBP' and csd_type='D' and csd_numb='0002'
GROUP BY csd_orig, csd_subj, csd_type, csd_numb

Andy

Beauty is in the eyes of the beerholder
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-27 : 02:58:45
[code]Select top 1 * from (
csd_orig, csd_subj, csd_type, csd_numb, csd_revi
from
e0362csd
where
csd_subj='SIBP' and csd_type='D' and csd_numb='0002'
) T order by csd_revi Desc[/code]

Madhivanan

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

SamC
White Water Yakist

3467 Posts

Posted - 2005-07-06 : 13:53:51
quote:
Originally posted by madhivanan

Select top 1 * from (
csd_orig, csd_subj, csd_type, csd_numb, csd_revi
from
e0362csd
where
csd_subj='SIBP' and csd_type='D' and csd_numb='0002'
) T order by csd_revi Desc


Madhivanan

Failing to plan is Planning to fail

Error Will Robinson

Select top 1 csd_orig, csd_subj, csd_type, csd_numb, csd_revi
from e0362csd
where csd_subj='SIBP' and csd_type='D' and csd_numb='0002'
order by csd_revi Desc

[/code]
Go to Top of Page
   

- Advertisement -