易截截图软件、单文件、免安装、纯绿色、仅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


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

求一sql语句 - MS-SQL Server / 疑难问题

现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......

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的问题 - .NET技术 / ASP.NET

将一个查询语句赋给一个变量,如下:
DECLARE @STR NVARCHAR(MAX)
SET @STR='SELECT * from SALE_PROD'
怎么样才能执行它呢?
请高手,仁兄,侠姐帮帮忙啊


多谢,可以啦,高手啊

直接执行就行了

exec ......

C# SQL 的UPDATETEXT 问题 - .NET技术 / C#

A表 有两个字段 
  id 唯一数字域
  InfoTxt text 类型
 我现在要把 id 不是14 的所有 InfoTxt字段 文本后面 都加上 'aaa' 
按下面执行下来 只有表最后一行加上了 'aaa' ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号