SQL語句 查詢 統計
* * from 學生表* 學號,姓名,年齡 from 學生表* 學號,姓名,年齡 from 學生表 where 年齡 between 18 and 20 and 系別='IS'* 學號,姓名,年齡 from 學生表 where 姓名 like '李%' or 姓名 like '李%'5 select distinct 學號 from 學生表 where 成績 <606. select 姓名,年齡,系名 from 學生表 where 系 in ('IS','CS') order by 系名 ASC,姓名 desc7 select count(*) from 學生表 where 系= 'IS'8 select count(*) ,max(分數),min(分數)from 學生表 9 select 課程號,count(*),avg(分數) from 學生表 group by課程號10 select 學號,count(*) from 學生表 11 select avg(分數),課程號 from 學生表 group by 課程號12 select avg(分數),課程號 from 學生表 group by 課程號 order by avg(分數)13 select count(*),學號 from 學生表 group by 學號14 select count(*)a,學號 from 學生表 group by 學號 order by a15 select 課程名稱,avg(分數) from 學生表 group by 課程名16 select 課程標號,課程名稱,avg(分數) from 學生表 group by 課程號,課程名17 select 課程名稱,avg(分數)a from 學生表 where a >7018 select 姓名,count(*) a from 學生表 group by 姓名19 select 學號,姓名,count(*) a from 學生表 group by 學號,姓名20select 學生姓名,count(*) a from 學生表 where a> 4 group by 學生姓名。
SQL語句 查詢 統計
* * from 學生表
* 學號,姓名,年齡 from 學生表
* 學號,姓名,年齡 from 學生表 where 年齡 between 18 and 20 and 系別='IS'
* 學號,姓名,年齡 from 學生表 where 姓名 like '李%' or 姓名 like '李%'
5 select distinct 學號 from 學生表 where 成績 6. select 姓名,年齡,系名 from 學生表 where 系 in ('IS','CS') order by 系名 ASC,姓名 desc
7 select count(*) from 學生表 where 系= 'IS'
8 select count(*) ,max(分數),min(分數)from 學生表
9 select 課程號,count(*),avg(分數) from 學生表 group by課程號
10 select 學號,count(*) from 學生表
11 select avg(分數),課程號 from 學生表 group by 課程號
12 select avg(分數),課程號 from 學生表 group by 課程號 order by avg(分數)
13 select count(*),學號 from 學生表 group by 學號
14 select count(*)a,學號 from 學生表 group by 學號 order by a
15 select 課程名稱,avg(分數) from 學生表 group by 課程名
16 select 課程標號,課程名稱,avg(分數) from 學生表 group by 課程號,課程名
17 select 課程名稱,avg(分數)a from 學生表 where a >70
18 select 姓名,count(*) a from 學生表 group by 姓名
19 select 學號,姓名,count(*) a from 學生表 group by 學號,姓名
20select 學生姓名,count(*) a from 學生表 where a>4 group by 學生姓名
求教一條關于統計的sql語句怎么寫
select '1',
(select count(1) from table where A = 1) A,
(select count(1) from table where B = 1) B,
(select count(1) from table where C = 1) C
union all
select '2',
(select count(1) from table where A = 2) A,
(select count(1) from table where B = 2) B,
(select count(1) from table where C = 2) C
union all
select '3',
(select count(1) from table where A = 3) A,
(select count(1) from table where B = 3) B,
(select count(1) from table where C = 3) C
union all
select '4',
(select count(1) from table where A = 4) A,
(select count(1) from table where B = 4) B,
(select count(1) from table where C = 4) C
……
我要把一個部門的人統計出來,用SQL語句怎么統計(包括男和女)?
下面的SQL語句(SYBASE),請參考: select *_bmmc as '部門', count(case when *_ygxb = '男' then 1 else 0 end) as '男', count(case when *_ygxb = '女' then 1 else 0 end) as '女' from hp_ygxx a,hp_bmxx b where *_bmbh = *_bmbh group by *_bmmc。
求教一個統計數量的sql語句
create table 訂單表 (
定單號 varchar(10), 狀態 int)
insert 訂單表 select
'DD1001' , 1 union select
'DD1002' , 1 union select
'DD1003' , 1 union select
'DD1004' , 0 union select
'DD1005' , 0 union select
'DD1006' , 1
go
create table 訂單詳細表 (
定單號 varchar(10), 物品名 varchar(10), 數量 int)
insert 訂單詳細表 select
'DD1001' , '語文書' , 30 union select
'DD1001' , '數學書' , 20 union select
'DD1001' , '電腦書' , 30 union select
'DD1002' , '電腦書' , 10 union select
'DD1003' , '政治書' , 30 union select
'DD1003' , '電腦書' , 15 union select
'DD1003' , '英語書' , 10 union select
'DD1003' , '語文書' , 6 union select
'DD1004' , '電腦書' , 5 union select
'DD1004' , '語文書' , 8 union select
'DD1005' ,'雜志' ,12 union select
'DD1005' , '小說' ,14 union select
'DD1005' , '電腦書' , 15 union select
'DD1005' , '語文書' , 21 union select
'DD1005' , '化學書' , 18 union select
'DD1006' , '物理書' , 22 union select
'DD1006' , '化學書' , 58union select
'DD1007' , '化學書' , 20
go
select 物品名,SUM(數量) as 數量
from 訂單詳細表 a join 訂單表 b on a.定單號=b.定單號
where b.狀態 = 1
group by 物品名
/*
物品名 數量
---------- -----------
電腦書 55
化學書 58
數學書 20
物理書 22
英語書 10
語文書 36
政治書 30
*/