求一條sql多條件查詢語句

2023-01-29 23:56:01 字數 704 閱讀 3737

1樓:匿名使用者

假設子女孩次為1或2的話:

select 姓名,

max(case 子女孩次 when 1 then 子女姓名 else null end) 一孩姓名,

max(case 子女孩次 when 1 then 子女性別 else null end) 一孩性別,

max(case 子女孩次 when 2 then 子女姓名 else null end) 二孩姓名,

max(case 子女孩次 when 2 then 子女性別 else null end) 二孩性別

from tab1

group by 姓名

2樓:匿名使用者

用sql的多表查詢語句就可以了:

就按你這個地址的**式回答你吧:

'select 總表.學號,總表.姓名,總表.

性別,分表.學號,分表.成績 from 總表,分表 where 總表.

學號=001 and 分表.學號=001'

大概,就是這樣了!

3樓:匿名使用者

額,這個

也是你問的?你去看那個吧 ,不寫了

C中SQL語句的多條件查詢, NET(c ) SQL 如何多條件查詢

你自己寫的sql語句就能完成任務啊,只是需要把引數傳入就可以了 string sqlquerytime string.format select from workdiary where time firstday and time lastday and name name net c sql 如...

一條sql語句

select 月,商品,sum 數量 as 銷量,sum 數量 as 銷售額into temp from 銷售表 group by 月,商品 select a.from temp a,select 月,max 銷量 as 最大銷量from temp group by 月 bwhere a.月 b.月...

求一條sql語句,查詢表,根據其中表的資料行數進行排序的問題

那就改一下關聯欄位就行了 select from 表a order by select count 1 from 表b where 使用者表id 表a.id 另外,您還可以把行數在查詢中顯示出來,並按照行數從多到少的順序排列 select select count 1 from 表b where 使...