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

sql 简单查询求助 - MS-SQL Server / 疑难问题

数据内容

no name
-----------
x1 wade
2d james
pk kobe
aa KG


希望结果为


no name no name
-------------------------
x1 wade 2d james
px kobe aa KG



SQL code:
create table tb (no varchar(5),name varchar(10))
insert tb
select 'x1', 'wade' union all
select '2d', 'james' union all
select 'pk', 'kobe' union all
select 'aa', 'KG'

select max(no1) no ,max(name1) name,max(no2) no ,max(name2) name from
(
select (row_number()over(order by getdate())-1)/2 rn,
(case when row_number()over(order by getdate())%2=1 then no else '' end) no1,
(case when row_number()over(order by getdate())%2=1 then name else '' end) name1,
(case when row_number()over(order by getdate())%2=0 then no else '' end) no2,
(case when row_number()over(order by getdate())%2=0 then name else '' end) name2
from tb
) t
group by rn

/*
no name no name
----- ---------- ----- ----------
x1 wade 2d james
pk kobe aa KG

(所影响的行数为 2 行)

*/



具体里面有多少记录是未知的


学习中

引用
具体里面有多少记录是未知的

那些测试语句你不用管.只需要这3句:

select * , id=identity(int,1,1) into tmp from tb


相关问答:

csv文件转换成sql导入到数据库,没有数据为何?

执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......

sql 问题 - MS-SQL Server / 基础类

需求如下:
学院 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语句问题 - Java / Web 开发

select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
我感觉没有区别啊,怎么在mysql会有 ......

asp wap sql语句中获取的汉字不好事 - Web 开发 / ASP

SQL code:

rs.open "select * from guide where city_name='北京' order by pai desc",conn,1,1
do while not rs.eof or rs.bof
。。
。。
。。
rs.movenext
loop
这个sql语句在wap站里 本身有 ......

Access通过Sql语句创建数据库 - .NET技术 / C#

在Access的查询中执行下面的语句,无效,提示期待select ,updata ,...
CreateTble C=Answer N="回帖表"
(
  C=ID T="INTEGER" P=No M=No N="编号" Z=false,
  C=Ques ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号