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.
| Author |
Topic |
|
sippon77
Starting Member
13 Posts |
Posted - 2005-04-06 : 05:54:05
|
| how do i get the max date (the latest one). currently i am doing the following:select top 1 @incidentid = vin.iincidentid, @prodesc = qd.vchdescription , @unitprice = cast(cast(qd.flunitprice as bigint) as varchar)from vincident vinjoin vquoteheader qhon qh.isystemid = vin.iincidentidand vin.iincidentcategory =3join vquotedetail qdon qd.iquoteid = qh.iquoteidwhere vin.iownerid = @cid order by vin.dtupdatedate descbut i dont want to be using 'order by' and 'top'.Thanks in advance!! |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-04-06 : 06:09:40
|
use max(dateColumn) and group byGo with the flow & have fun! Else fight the flow |
 |
|
|
kimberr
Starting Member
9 Posts |
Posted - 2005-04-06 : 06:20:12
|
| If you want to return the iincidentid relating to the iownerid record with the MAX date. Add this where clause to main query:where [datefield] = (select max([datefield]) from vincident where vin.iownerid = @cid) |
 |
|
|
|
|
|