求sql语句 - MS-SQL Server / 疑难问题
我有表books
ID 条形码 分类号
1 1001 A
2 1002 B
4 1003 C
5 1005 D
6 1006 E
7 1007 F
8 1008 G
想通过sql语句,实现下面六列显示效果
条形码1 分类号1 条形码2 分类号2 条形码3 分类号3
1001 A 1002 B 1003 C
1005 D 1006 E 1007 F
1008 G
希望高手解答,在此感谢各位!
行转化列
对于这种不大有规律可寻的我不会转,希望各位指教!
--sql 2000
SQL code:
create table books(ID int,条形码 varchar(10),分类号 varchar(10))
insert into books values( 1 ,'1001', 'A')
insert into books values( 2 ,'1002', 'B')
insert into books values( 4 ,'1003', 'C')
insert into books values( 5 ,'1005', 'D')
insert into books values( 6 ,'1006', 'E')
insert into books values( 7 ,'1007', 'F')
insert into books values( 8 ,'1008', 'G')
go
--sql 2000
select
max(case (px - 1) % 3 when 0 then 条形码 else '' end) [条形码1],
max(case (px - 1) % 3 when 0 then 分类号 else '' end) [分类号1],
max(case (px - 1) % 3 when 1 then 条形码 else '' end) [条形码2],
max(case (px - 1) % 3 when 1 then 分类号 else '' end) [分类号2],
max(case (px - 1) % 3 when 2 then 条形码 else '' end)
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
sql的软件在哪里可以下啊!在网上找了蛮多都用不了啊
随便搞一D版吧,
迅雷第一个就可以用
2000,2005都这样
http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......
如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP
参考:http://hi.baidu.com/toiota ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......