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 |
ktkn
Starting Member
13 Posts |
Posted - 2012-12-04 : 15:47:07
|
I have tbl_sale table below with two columnsorderNo purchaseNo123 50123 10456 20789 40There are many purchaseNo within the table and don't know what is the min value is. I have the query below to get the min number for particular orderNo but not sure if mine sysntax is correctted?The result i want isorderNo purchaseNo123 10Thanks SELECT orderNo, purchaseNoFROM tbl_salewhere purchaseNo = (SELECT MIN(purchaseNo) FROM tbl_sale where orderNo = 123) and orderNo = 123 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-04 : 15:57:21
|
select orderno,min(purchaseNo)from tbl_salegroup by orderno |
|
|
|
|
|