導航:首頁 > 編程大全 > sql資料庫統計男女人數

sql資料庫統計男女人數

發布時間:2024-09-29 11:21:51

❶ SQL 資料庫中如何統計指定數據的個數 高分急尋

select count(1) from table_name where 姓名1 = 'mary' +
select count(1) from table_name where 姓名2 = 'mary' +
select count(1) from table_name where 姓名3 = 'mary'+
select count(1) from table_name where 姓名4 = 'mary'+
select count(1) from table_name where 姓名5 = 'mary'

select count(*)
from (
select name1 from table_name
union all
select name2 from table_name
union all
select name3 from table_name
union all
select name4 from table_name
union all
select name5 from table_name
) t
where name1='mary'
笨而簡單的方法,想一步完成,寫個函數吧

❷ 求資料庫sql2008語句

1. 查詢年齡大於25歲的女學生的學號和姓名。
select 學號,姓名 from 學生 where datediff(year,'出生日期',getdate())>25;
2. 查詢學生姓名和出生年份(並給出生年份取別名)
select 姓名,year(出生日期) as '出生年份' from 學生;
3. 統計選修了2號課程的人數
select count(1) from 選課 where 課號='2';
4. 查詢選修了2號課程的平均分
select avg(成績) from 選課 where 課號='2';
5. 統計計算機科學系的學生人數
select count(1) from 學生 where 所在系='計算機科學系';
6. 查詢成績在60到80之間的所有記錄(包括60和80)
select * from 選課 where 成績 between 60 and 80;
7. 查詢成績為85,86或88的記錄
select * from 選課 where 成績 in('85','86','88');
8. 查詢年齡不在19到21歲之間的學生姓名和年齡
select 姓名,datediff(year,'出生日期',getdate()) from 學生 where datediff(year,'出生日期',getdate())<19 or datediff(year,'出生日期',getdate())>21;
9. 查詢所有不姓王的學生記錄
select * from 學生 where 姓名 not like '王%';
10. 查詢所有姓王,且名字只有兩個字的學生名字
select 姓名 from 學生 where left(姓名,1)='王' and LEN(TRIM(姓名))=2;
11. 查詢所有課程名是「db_」開頭的課程名字
給出信息應該缺一個課程表
12. 以系別和年齡從大到小的順序查詢學生表中的全部記錄
select * from 學生 order by 所在系 desc,出生日期 asc;
13. 查詢姓名的第二個字為「小」字的女生信息
select * from 學生 where 性別='女' and SUBSTRING(姓名,2,1)='小';
14. 查詢成績最高的三個學生的學號和成績(取前幾條數據用「top 數字」)
select top 3 學號,成績 from 選課 order by 成績 desc;
15. 查詢學生的成績信息,先按學號升序排序,再按成績降序排序。
select * from 選課 order by 學號 asc,成績 desc;

❸ SQL資料庫的問題,請問怎麼樣查詢所有性別女的

我來幫你寫吧,上的代碼有問題。我已經測試好了,通過比較慢,你等等

閱讀全文

與sql資料庫統計男女人數相關的資料

熱點內容
c盤oem文件夾 瀏覽:776
一人我飲酒醉多版本的 瀏覽:845
海克斯康三次元如何編程循環測量 瀏覽:518
app無法下載是為什麼蘋果手機 瀏覽:518
右擊此電腦管理找不到此文件 瀏覽:264
圖像文件格式百科 瀏覽:523
沒有網路怎麼定位 瀏覽:972
剪切到優盤文件找不到了 瀏覽:764
電腦管家的文件名 瀏覽:910
如何將掃描文件轉換為電子版 瀏覽:4
u盤的h246文件怎麼播放 瀏覽:203
如何用阿里雲伺服器學習資料庫 瀏覽:84
華為文件管理找不到下載文件 瀏覽:409
word模板dot的使用 瀏覽:466
春節車找人app哪個好 瀏覽:618
文件管理電腦找不到了怎麼辦 瀏覽:516
如何改變app圖標圖片 瀏覽:767
什麼是大數據結構的最低層 瀏覽:575
pdf文件給對方後期改密碼收回 瀏覽:295
word2010怎麼畫箭頭 瀏覽:184

友情鏈接