首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求sql话语~

2013-07-01 
求sql语句~~~~~~~sql2005,现在有个表course_time,里面有AMsection;PMsection字段(int),分别代表上午几节课

求sql语句~~~~~~~
sql2005,现在有个表course_time,里面有AMsection;PMsection字段(int),分别代表上午几节课,下午几节课;现在想根据这个值,用语句列出多行;
效果为:
上午第1节
上午第2节
.
.
.
下午第1节
.
.
这里的具体几行,是根据上面那2个字段得到的
[解决办法]


with tb(AMsection,PMsection) as(
select 4,3)
select '上午第'+convert(varchar,number)+'节' from master..spt_values a,tb
where type='p' and number>0 and number<=AMsection
union all
select '上午第'+convert(varchar,number)+'节' from master..spt_values a,tb
where type='p' and number>0 and number<=pMsection

热点排行
Bad Request.