sql語句,實現在查詢結果中顯示每5行後加一空白行

2021-05-01 20:57:03 字數 1461 閱讀 9851

if not object_id('[tb]') is null

drop table [tb]

gocreate table [tb]([id] int,[p_title] nvarchar(30),[p_company] nvarchar(50),[p_time] datetime)

insert tb

select 1,'資料庫','oracle_1','2009-08-06' union all

select 2,'資料庫','sql server 2000','2009-08-06' union all

select 3,'資料庫','sql server 2005','2009-08-06' union all

select 7,'資料庫','sql server 2008','2009-08-06' union all

select 8,'作業系統','ms dos','2009-08-06' union all

select 9,'作業系統','windows 95','2009-08-06' union all

select 12,'作業系統','windows 98','2009-08-06' union all

select 14,'作業系統','windows 2000','2009-08-06' union all

select 15,'作業系統','windows 2000 server','2009-08-06' union all

select 16,'作業系統','windows xp pro','2009-08-06' union all

select 17,'作業系統','windows 2003 server ent','2009-08-06' union all

select 18,'作業系統','windows 2008 ent','2009-08-06' union all

select 19,'列車','昆明-成都2003次','2009-08-06' union all

select 20,'列車','昆明-成都2640次','2009-08-06' union all

select 21,'列車','昆明-成都2650次','2009-08-06' union all

select 23,'列車','昆明-成都k938次','2009-08-06' union all

select 25,'列車','昆明-北京t62次','2009-08-06'

goselect [id],[p_title],[p_company],[p_time]

from (

select rn=(select count(1) from tb where idfrom tb t

union all

select distinct (select count(1) from tb where idfrom tb t

) as t

order by rn,px

SQL語句查詢結果轉excel

直接輸出到servlet可以不用在硬碟上寫檔案 int rows l.size 行數 system.out.println l.size for int i 1 i 取得輸出流 outputstream out res.getoutputstream 清空輸出流 res.reset res.seth...

SQL語句(十)查詢結果排序

例1 查詢航天班的學生的姓名 年齡 按年齡從小到大排序 公升序 select sname,sage from student where sclass 航天 order by sage asc 降序 asc 改成 desc 例2 查詢航天的學生資訊按年齡從大到小排序 降序 年齡相同時按學號公升序排列...

關於SQL查詢語句合併結果集

整理別人的sql 大概的思想是用union 和union all 合併重複行 select from a union select from b 不合併重複行 select from a union all select from b 按某個字段排序 合併重複行 select from select...