-
行转列场景:如报表统计,汇总显示等查看全部
-
通过存储过程和事务等确保生成唯一序列号。可以通过创建一张表,记录某天的流水号最大是什么,然后通过某一个数可以叠加起来。查看全部
-
序列号查看全部
-
先把字段值串联起来,然后统计多少个字段串联。再用一张序列表 cross join 上面串联好的表。最好一步就是要实现多少个字段串联了有多少行。因为是笛卡尔乘积 where id <=size也是就是上面串联多少行字段。查看全部
-
使用SQL生成唯一的序列号查看全部
-
使用Union实现列行转换查看全部
-
列转行查看全部
-
删除重复数据 delete a from user1_test a join ( select user_name,count(*),max(id) as id from user1_test group by user_name having count(*)>1) b on a.user_name=b.user_name where a.id<b.id查看全部
-
列转行2 select user_name,'arms' as equipment, arms from user1 a join user1_equipment b on a.id=user_id union all select user_name,'clothing' as equipment, clothing from user1 a join user1_equipment b on a.id=user_id; union all select user_name,'shoe' as equipment, shoe from user1 a join user1_equipment b on a.id=user_id;查看全部
-
列转行 select user_name,replace(substring(substring_index(mobile,','a.id),char_length(substring_index(mobile,',',a.id-1))+1),',','') as mobile from tb_sequence as a cross join( select user_name,concat(mobile,',') as mobile,length(mobile)-length(replace(mobile,',',''))+1 as size from user1 as b) as b on a.id<=b.size查看全部
-
行列转换 declare @sql nvarchar(1000) set @sql='select cl ' select @sql=@sql+',sum(case when ck='''+ck+''' then sl else 0 end) as '''+ck+'''' from table1 group by ck set @sql=@sql+' from table1, group by cl' execute sp_execute sql @sql查看全部
-
删除字段中的重复数据查看全部
-
case实现行转列。查看全部
-
处理重复数据查看全部
-
存储过程查看全部
举报
0/150
提交
取消