求一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
相关问答:
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......
有这样一条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. ......