求一SQL语句 - MS-SQL Server / 应用实例
有一表A有栏位 成品SN1,包装SN2
SN1 SN2
1 1
2 1
3 1
4 1
5 1
6 2
7 2
8 2
9 2
10 2
需要的结果是
ROWID SN1 SN2
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
1 6 2
2 7 2
3 8 2
4 9 2
5 10 2
SQL code:
--05
select rowid=row_number()over(partition by sn2 order by sn1),* from A
--2k
select rowid=(select count(1) from A t where sn2=a.sn2 and sn1<=a.sn1),* from A
SQL code:
create table tb(sn1 int,sn2 int)
insert into tb values(1,1)
insert into tb values(2,1)
insert into tb values(3,1)
insert into tb values(4,1)
insert into tb values(5,1)
insert into tb values(6,2)
insert into tb values(7,2)
insert into tb values(8,2)
insert into tb va
相关问答:
如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP
参考:http://hi.baidu.com/toiota ......
需求如下:
学院 academy(aid,aname)
班级 class(cid,cname,aid)
学生 stu(sid,sname,aid,cid)
住宿区 region(rid,rname)
宿舍楼 build(bid,rid,bnote) bnote是‘男’/‘女’
宿舍 dorm(did,rid,bid,bedn ......
有这样一条SQL
Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......
原SQL语句SQL code:
SELECT t6.FName '操作工',t1.FDate '日期',t5.FName '制单人',t3.FName '设备',t4.FName '班制',
t7.FBillNo '工艺指令单号',t8.FName '岗位',t2. ......