Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct on third column

Status
Not open for further replies.

TekLight

Programmer
Jan 16, 2009
2
US

Hi,
I have a table like this ,how to get all three columns in a SELECT query with distinct NEWORDER values :

ID OLDORDER NEWORDER
4853814 NULL 1Z6W688A0196725307
4878543 NULL 1Z6W688A0497292312
4878543 798377318718 798377318718
4878543 798377318718 798377318718

any help please ?
 
You could do something like
Code:
SELECT MAX(ID) AS MXID, NEWORDER FROM MyTable GROUP BY NewOrder
Then add in the OldOrder value.

However with the data shown a simple distinct would work
Code:
SELECT DISTINCT * FROM MYTABLE

Though I may not understand the problem properly.

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top