34,590
社区成员
发帖
与我相关
我的任务
分享
SqlDataAdapter myda = new SqlDataAdapter("select a.考场,b.座号 from (select 考场 from tb2 where 考场 between 1 and 2) a cross join (select 座号 from tb2 where 座号 between 1 and 30) b", con);
DataSet da = new DataSet();
myda.Fill(da);
GridView1.DataSource = da.Tables[0];
GridView1.DataBind();
SqlCommand myda=new SqlCommand("select a.考场,b.座号 from (select number '考场' from master.dbo.spt_values where type='P' and number between 1 and 2) a cross join (select number '座号' from master.dbo.spt_values where type='P' and number between 1 and 30) b", con);
myda.ExecuteNonQuery();
con.Close();
select a.组名,b.序号,'xxx' 姓名 from
(select number '组名'
from master.dbo.spt_values
where type='P' and number between 1 and 2) a
cross join
(select number '序号'
from master.dbo.spt_values
where type='P' and number between 1 and 30) b
/*
组名 序号 姓名
----------- ----------- ----
1 1 xxx
1 2 xxx
1 3 xxx
1 4 xxx
1 5 xxx
1 6 xxx
1 7 xxx
1 8 xxx
1 9 xxx
1 10 xxx
1 11 xxx
1 12 xxx
1 13 xxx
1 14 xxx
1 15 xxx
1 16 xxx
1 17 xxx
1 18 xxx
1 19 xxx
1 20 xxx
1 21 xxx
1 22 xxx
1 23 xxx
1 24 xxx
1 25 xxx
1 26 xxx
1 27 xxx
1 28 xxx
1 29 xxx
1 30 xxx
2 1 xxx
2 2 xxx
2 3 xxx
2 4 xxx
2 5 xxx
2 6 xxx
2 7 xxx
2 8 xxx
2 9 xxx
2 10 xxx
2 11 xxx
2 12 xxx
2 13 xxx
2 14 xxx
2 15 xxx
2 16 xxx
2 17 xxx
2 18 xxx
2 19 xxx
2 20 xxx
2 21 xxx
2 22 xxx
2 23 xxx
2 24 xxx
2 25 xxx
2 26 xxx
2 27 xxx
2 28 xxx
2 29 xxx
2 30 xxx
(60 row(s) affected)
*/
select 组名,count(*) as 人数
from tb
group by 组名