July 12, 2011 at 4:26 am
Hello All
First time poster, so please be gentle
I have built a query that pulls out various bits of data from multiple tables but now I have been asked to add to this.
I obtain a list of names and then the maximum amount they have spent in a one off transaction during a given time period. Within the table that the amount comes from each amount is assigned a ref number. I need to get the ref number for the max amount.
hope I have explained this well enough, if not please advise what you need.
July 12, 2011 at 4:38 am
Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 12, 2011 at 4:46 am
Thanks for the info I will take a look
July 12, 2011 at 7:30 pm
If I understand you correctly, you want accompanying detail (refID) to go with the maximum value. Basically you want information for the top row (sorted by value) in each group. If this assumption is correct, there are several ways to do this. Three of the most common are illustrated here[/url].
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply