Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to get data

Author  Topic 

sks198117
Starting Member

46 Posts

Posted - 2006-08-24 : 11:16:51
I have a table with following data col name refNo
refNo
---
ABC-0
ABC-1
XYZ-0
XYZ-1
XYZ-2
PQR-0
MNO-0
MNO-1
SPX-0
SPX-1

i want the result as below
ABC-1
XYZ-2
PQR-0
MNO-1
SPX-1

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-24 : 11:19:06
select max(refNo)
from tbl
group by left(refNo,3)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sks198117
Starting Member

46 Posts

Posted - 2006-08-24 : 11:21:47

How can i use max with char?


quote:
Originally posted by nr

select max(refNo)
from tbl
group by left(refNo,3)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-24 : 11:23:35
by coding it?
not sure what that question is.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2006-08-24 : 13:22:10
sks198117,

quote:

How can i use max with char?



Because it works with char? <g> Really, it does - it uses the ASCII values of each character to "score" it.

Ken
Go to Top of Page
   

- Advertisement -