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 |
|
pizzojm
Starting Member
20 Posts |
Posted - 2003-08-26 : 14:59:40
|
| I have a cost table which stores cost for a store and item everytime the cost is updated. It inserts a new row each time this happens with the date, it does not simply update the existing record. The problem is I need a daily report that pulls the most recent cost for every item and every associated store. I can't seem to do this and retrieve one record and one date. The table schema is as follows and any help would be greatly appreciated!...cost_key serialitem_num integerstore_num smallintcost_date datecost money(10,4) |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-08-26 : 15:47:26
|
| select *from tblwhere cost_date = (select max(t1.cost_date) from tbl t1 where t1.cost_key = tbl.cost_key and t1.item_num = tbl.item_num and t1.store_num = tbl.store_num)Not sure what cost_key is - you may have to drop it from the subquery.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|