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 |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2008-08-13 : 14:55:13
|
| I have an order detail table. I want to grab the unit price field out of the table which has the highest requested date. So if a record has a request date of today I want the unit price from that record. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-08-13 : 14:56:11
|
| you'll have to show us your table structure for this._______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2008-08-13 : 14:58:06
|
| Not sure exactly what you need. Table: OELINHSTFIELDS: ORD_NOITEM_NOCUS_NOREQUESTED_DTUNIT_PRICE |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-08-13 : 15:01:23
|
| table structure, sample data and expected result based on that sample data.select * from OELINHSTwhere REQUESTED_DT = (select max(REQUESTED_DT) from OELINHST where REQUESTED_DT < getdate())_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-14 : 01:17:43
|
or this (not sure what you exactly want)SELECT m.*FROM OELINHST mINNER JOIN (SELECT ORD_NO,MAX(REQUESTED_DT) AS MaxDate FROM OELINHST GROUP BY ORD_NO)tON t.MaxDate=m.REQUESTED_DTAND t.ORD_NO=m.ORD_NO |
 |
|
|
|
|
|