there are some data like this:
name number
12_PAGE19901_CHN.DISPLAY_NT n.115
12_PAGE19901_CHN.DISPLAY_NT n.114
KAITEST123.DISPLAY_NT n.110
KAITEST123.DISPLAY_NT n.109
KAITEST123.DISPLAY_NT n.108
KAITEST123.DISPLAY_NT n.107
KAITEST33333.DISPLAY_NT n.105
I want retrieve some data like this:
name number
12_PAGE19901_CHN.DISPLAY_NT n.115
KAITEST123.DISPLAY_NT n.110
KAITEST33333.DISPLAY_NT n.105
I need the first
value of number for each particular name, is this possible?
It appears that you just need the max value of number
for each particular name
.
SELECT
name,
MAX(number) AS number
FROM
yourTable
GROUP BY
name
Be aware that as number
is an alpha-numeric field; n.09
is 'higher' than n.011
. To make this more numerically consistent , you would need n.009
instead of n.09
.
(As I don't know the behaviour of your number field, this is just a general note, not about your example data.)
If you want the max for number
and group by name
, try this.
select name, max(number) as number
from TABLE
group by name
SELECT name,
'n.' + Cast(Max(Cast(Substring([number], 3, Len([number]) - 2) AS INT))
AS
VARCHAR(10))
FROM table
GROUP BY name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.