November 24, 2010 at 1:23 pm
My table has Order, Release, Line and many other columns. I want to select just the top 1 line for every distinct Order and Release combination. I don't care which line I get because the other columns I want to retrieve are the same for all rows.
How can I get a distinct list based on these two key fields, but still grab a couple other columns like Ref1 and Ref2.
November 24, 2010 at 2:34 pm
It would assist those who would like to assist you if you would post the table definition, some sampe data and desired results from that sample data. Refer to the first link in my signature block to see how to do this most easily..
November 24, 2010 at 2:38 pm
mpv-1060508 (11/24/2010)
My table has Order, Release, Line and many other columns. I want to select just the top 1 line for every distinct Order and Release combination. I don't care which line I get because the other columns I want to retrieve are the same for all rows.How can I get a distinct list based on these two key fields, but still grab a couple other columns like Ref1 and Ref2.
Have you tried?:
SELECT order, release, MAX(Line) AS Line, ... FROM table GROUP BY order, release
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply