SQL Server Max函数.......... [英] Sql Server Max function...................
本文介绍了SQL Server Max函数..........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据库中将VARCHAR字段命名为Userid
DDP-1,DDP-2,DDP-3等中的值
我想使用SQL QUERY从中选择最大值
即;
来自
DDP-1
DDP-2
DDP-3
我需要从上面的列表中获取3作为该字段的最大值,
如果有必要,请帮助我
I Have a VARCHAR field in DB naming Userid
The value in it like DDP-1,DDP-2,DDP-3 etc
i want to select max from that using SQL QUERY
ie;
from
DDP-1
DDP-2
DDP-3
i need to get 3 from above list as max of that field,
please help me if there is anyway to do it
推荐答案
嗨 Kishore,
我假设您只想要 Number .这是解决方案
Hi Kishore,
i assume you want only Number. Here is solution
SELECT REPLACE(MAX(departmentid),'DDP-','') FROM department
谢谢,
Imdadhusen
Thanks,
Imdadhusen
希望 Max() [
Hope Max()[^] will give you an idea.
选择top(1)表名顺序中的用户ID按用户ID desc
select top(1) userid from tablename order by userid desc
这篇关于SQL Server Max函数..........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文