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 |
GordonCopestake
Starting Member
8 Posts |
Posted - 2012-03-16 : 12:54:16
|
Hi all,I have a table CustomerPrices that lists all the prices of items and the dates the prices were set. The current price of an item is the latest date for the group of items. I would like to make a view that ONLY shows the current prices for each item.e.g.itemID | price | DateSetapple | $0.50 | 01/01/01orange | $1.00 | 02/03/02apple | $0.55 | 01/03/01apple | $0.67 | 05/07/02pear | $3.20 | 05/03/05orange | $2.00 | 06/03/06desired output from viewitemID | Price | DateSetapple | $0.67 | 05/07/02orange | $2.00 | 06/03/06pear | $3.20 | 05/03/05Could someone point me in the right direction? I'm thinking I am having to play with groupings and MAX of DateSet but I can't seem to get my head around it.Thanks in advanceGordon |
|
X002548
Not Just a Number
15586 Posts |
|
GordonCopestake
Starting Member
8 Posts |
Posted - 2012-03-16 : 13:08:37
|
Brett, many thanks for your swift reply!This works beautifully in a query but not in a view :-(Is there a way to get the same functionality in a view? |
 |
|
X002548
Not Just a Number
15586 Posts |
|
GordonCopestake
Starting Member
8 Posts |
Posted - 2012-03-16 : 13:50:33
|
Ignore me i'm being a dumbass!Works fine thanks!I was trying to execute it in the view design pane in management studio and it was giving errors, but it works fine from a query window which is all that matters.Thanks Brett |
 |
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|