一个sql查询的问题,望不吝赐教……

一个会员表里,怎么查询,才能使查出的结果是

一行男

一行女

一行男

一行女

一行男

一行女

…………


慕姐4208626
浏览 936回答 1
1回答

慕雪6442864

use tempdb godeclare @tb table(name nvarchar(20),sex nvarchar(10))insert into @tb select '张三','男'union allselect '李四','男'union allselect '王五','男'union allselect '赵六','女'union all select '曹七','女'select * from @tbdeclare @newtb table(name nvarchar(20),sex nvarchar(10),ID int)declare @tbman table(name nvarchar(20),sex nvarchar(10),ID int identity(1,2))declare @tbwoman table(name nvarchar(20),sex nvarchar(10),ID int identity(2,2))insert into @tbman select * from @tb where sex='男'insert into @tbwoman select * from @tb where sex='女'insert into @newtbselect * from @tbman union allselect * from @tbwoman order by IDselect * from @newtb
打开App,查看更多内容
随时随地看视频慕课网APP