这个select语句该怎么写!???! 大虾们请快快出手相救啊!!!! select a.*,(case when a.b=b.b then 'Y' else 'N' end) as IfMax from table a,(select a,max(b) as b from table group by a) b where a.a=b.a 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select a,b ,'N' from table where a>bunionselect a,b ,'Y' from table where a<=b select *,case when b = (select max(b) from Tab where a = t1.a) then 'Y' else 'N' endfrom Tab T1 select * ,case when b = (select max(b) from ab where a = t1.a) when 'Y' else 'N' end AS ifmaxfrom ab T1 to j9988(j9988) : 呵呵, 谢谢, 搞定了to zqllyh:如果记录如下,你的方法是不行的, :)a b-----------------10 110 210 310 42 12 20 select * ,case when b = (select max(b) from Tab where a = t1.a) when 'Y' else 'N' end AS ifmaxfrom Tab T1这个难道不更好马?! 如何创建 链接服务器啊? 新手提问:为什么捕捉不到@@ERROR 求一存储过程 排序问题 有链接语句,怎么样把数据库导入导入到本地 如何删除引起I/O错误的数据? 急急急 将sql server 2000 数据库中某个表中的数据导出 在SQL怎么样做打印? 【求救】asp板块没人搞定!sql语句分页算法,只支持单表操作,我多表取数据时就发现只能永远去前一页的数据, dts中的问题!关于日期(大力帮忙) 求SQL写法:在表中求出一字段有相等值的纪录. SQL的自带存储过程sp_attach_single_file_db的错误
union
select a,b ,'Y' from table where a<=b
else 'N' end
from Tab T1
,case when b = (select max(b) from ab where a = t1.a) when 'Y' else 'N' end AS ifmax
from ab T1
如果记录如下,你的方法是不行的, :)
a b
-----------------
10 1
10 2
10 3
10 4
2 1
2 20
,case when b = (select max(b) from Tab where a = t1.a) when 'Y' else 'N' end AS ifmax
from Tab T1这个难道不更好马?!