469,890 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

finding the max

110 100+
I have a table as follows

code
PB0001AA
PB0001AB
PB0001AC
PX0001AA
PX0001AB
PX0001AC
PX0001AD
PC0001AA
PC0001AB


I want to get data of only max
eg in the above case
PB0001AC
PX0001AD
PC0001AB







Thanks in advance
Apr 19 '13 #1
4 1128
SSG001
110 100+
Expand|Select|Wrap|Line Numbers
  1. SELECT MAX(code) FROM exmaster WHERE code IN (SELECT code FROM exmaster) GROUP BY SUBSTRING(code,1,6)
is this ok ?
Apr 20 '13 #2
SSG001
110 100+
Expand|Select|Wrap|Line Numbers
  1. SELECT MAX(code) FROM exmaster WHERE GROUP BY SUBSTRING(code,1,6)
Apr 20 '13 #3
vijay6
158 100+
Hey SSG001, you can use like this,

Expand|Select|Wrap|Line Numbers
  1. select MAX(Name) from Table_1 where Name like 'PB0001A%' union select MAX(Name) from Table_1 where Name like 'PX0001A%' union select MAX(Name) from Table_1 where Name like 'PC0001A%'
Apr 20 '13 #4
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

You can do this:
Expand|Select|Wrap|Line Numbers
  1. SELECT MAX(code)
  2. FROM exmaster
  3. GROUP BY SUBSTRING(code,1,6)
Apr 20 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Tristan | last post: by
11 posts views Thread by Fuzzyman | last post: by
1 post views Thread by Phil Watkins | last post: by
3 posts views Thread by KL | last post: by
8 posts views Thread by Rick Strahl [MVP] | last post: by
2 posts views Thread by ElkGroveR | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.