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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query question 2

Status
Not open for further replies.

MinnisotaFreezing

Programmer
Jun 21, 2001
120
KR
Hello,

I have data with the records

number letter
1 a
1 b
1 c
2 a
2 b
3 a
3 b
3 c
My question is, how can I return the following data set using SQL
1 c
2 b
3 c
That is, the number with its highest corresponding letter?

Does that makes sense? Is this the right forum for this question? Thanks for your help in advance.

CJB
 
hi,

I'm not at a computer where I can test sql's but give this one a try:

"SELECT first(numberfield_name), max(letterfield_name) AS output FROM tablename GROUP BY numberfield_name;"

grtz
CPUburn

 
Or like this:
SELECT numberfield_name, max(letterfield_name)
FROM tablename
GROUP BY numberfield_name
ORDER BY numberfield_name;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top