易截截图软件、单文件、免安装、纯绿色、仅160KB

求一SQL语句 - MS-SQL Server / 基础类

描述:
表中有若干字段,其中,主键为:
行号,编号,组别
列举数据:
标识 行号 编号 组别 ......
1 1 S001 1
2 2 S001 1
3 2 S001 2
4 2 S001 3
5 3 S001 1 .......
6 1 S002 1

先求一SQL语句实现 根据编号检索出其中对应的记录,
要求,当行号重复时,取组别最大者

如果检索编号为S001的记录,上述数据检索结果为:
标识 行号 编号 组别 ......
1 1 S001 1
4 2 S001 3
5 3 S001 1 .......
在线等,请高手指教

SQL code:
select
*
from
tb t
where
组别=(select max(组别) from tb where 行号=t.行号)


SQL code:
select * from tb t where not exists(select 1 from tb where 行号=t.行号 and 组别>t.组别)


SQL code:

select t.* from tb t where 组别 = (select max(组别) from tb where 行号 = t.行号)
select t.* from tb t wh


相关问答:

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

ASP链接SQL的简单登陆界面 - .NET技术 / ASP.NET

protected void btnLogin_Click(object sender, EventArgs e)
  {
  SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

SQL server分解XML - MS-SQL Server / 应用实例

下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号