Click here to Skip to main content
15,917,997 members
Home / Discussions / Database
   

Database

 
AnswerRe: between max() and min() Pin
MatthysDT28-Aug-08 1:34
MatthysDT28-Aug-08 1:34 
Questionarray Pin
nelsonpaixao27-Aug-08 13:09
nelsonpaixao27-Aug-08 13:09 
AnswerRe: array Pin
Ashfield27-Aug-08 20:57
Ashfield27-Aug-08 20:57 
AnswerRe: array Pin
MatthysDT28-Aug-08 1:56
MatthysDT28-Aug-08 1:56 
Questiontable Pin
nelsonpaixao27-Aug-08 13:02
nelsonpaixao27-Aug-08 13:02 
AnswerRe: table Pin
Ashfield27-Aug-08 20:50
Ashfield27-Aug-08 20:50 
AnswerRe: table Pin
TheFM23428-Aug-08 16:54
TheFM23428-Aug-08 16:54 
QuestionGrouping by most recent date Pin
Netblue27-Aug-08 8:21
Netblue27-Aug-08 8:21 
I have a table called CostAverage which stores the average value of an item and the date that it was calculated on. Each item has its cost average calculated on different days, and only when changes are made to the item. Since the OnDate could be anything, and the table retains the history, I am looking for a way to get the most recent cost average for each item in the table. Here is a snapshot of the table:

CostAverage
PK CostAverageID
FK UserItemID
CostAverage
OnDate

At first glance, I threw down something like this:

SELECT UserItemID, CostAverage, MAX(OnDate)
FROM CostAverage
GROUP BY UserItemID, CostAverage

Since the CostAverage is always different, that of course returns nearly the entire table. I can't really use an aggregate on the CostAverage since I need the most recent.

Does anyone have a suggestion? I am sure that I wrote a similar query once in the past, but I can't seem to find it (or remember it)
AnswerRe: Grouping by most recent date Pin
Ashfield27-Aug-08 8:57
Ashfield27-Aug-08 8:57 
GeneralRe: Grouping by most recent date Pin
Netblue27-Aug-08 9:07
Netblue27-Aug-08 9:07 
GeneralRe: Grouping by most recent date Pin
Ashfield27-Aug-08 21:53
Ashfield27-Aug-08 21:53 
Questionhow to find string existence in the another string . Pin
lakshmichawala27-Aug-08 2:32
lakshmichawala27-Aug-08 2:32 
AnswerRe: how to find string existence in the another string . Pin
Ashfield27-Aug-08 2:37
Ashfield27-Aug-08 2:37 
GeneralRe: how to find string existence in the another string . Pin
lakshmichawala27-Aug-08 2:54
lakshmichawala27-Aug-08 2:54 
GeneralRe: how to find string existence in the another string . Pin
Ashfield27-Aug-08 2:55
Ashfield27-Aug-08 2:55 
AnswerRe: how to find string existence in the another string . Pin
Blue_Boy27-Aug-08 3:12
Blue_Boy27-Aug-08 3:12 
AnswerRe: how to find string existence in the another string . Pin
Wendelius27-Aug-08 6:50
mentorWendelius27-Aug-08 6:50 
QuestionHow to read sql server2000/2005 transaction log user friendly way? Pin
Tridip Bhattacharjee27-Aug-08 1:56
professionalTridip Bhattacharjee27-Aug-08 1:56 
AnswerReading the transaction log - Nope Pin
David Mujica27-Aug-08 3:55
David Mujica27-Aug-08 3:55 
GeneralRe: Reading the transaction log - Nope Pin
Netblue27-Aug-08 8:27
Netblue27-Aug-08 8:27 
AnswerAudit table format Pin
David Mujica27-Aug-08 10:16
David Mujica27-Aug-08 10:16 
Questionneed help with inner join and oount sql server 2005 Pin
VijayVishwakarma27-Aug-08 0:19
VijayVishwakarma27-Aug-08 0:19 
AnswerRe: need help with inner join and oount sql server 2005 Pin
Ashfield27-Aug-08 1:33
Ashfield27-Aug-08 1:33 
GeneralRe: need help with inner join and oount sql server 2005 Pin
neilmajithia27-Aug-08 4:15
neilmajithia27-Aug-08 4:15 
GeneralRe: need help with inner join and oount sql server 2005 Pin
VijayVishwakarma27-Aug-08 4:37
VijayVishwakarma27-Aug-08 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.