當前位置:首頁 » 編程語言 » sql篩選對方科目
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql篩選對方科目

發布時間: 2023-01-25 18:08:41

sql語句篩選及格成績

以下語句可實現只顯示同學的及格成績:
select 學號,語文=(case when 語文>=60 then 語文 else Null end),數學=(case when 數學>=60 then 數學 else Null end),英語=(case when 英語>=60 then 英語 else Null end) from 成績表 where 語文>=60 or 數學>=60 or 英語>=60

② 請問sql表內如何篩選數據

select 編號, 客戶名稱, 日期, 品名, 型號, 數量, 材質, 單價, 備注, 已發貨數量 from [表] where 數量<>已發貨數量

③ 用sql語句進行篩選

select姓名from表where課程!='A'

④ SQL怎麼取出每個科目前三名並按科目和分組排列

select B1.姓名,B1.科目,B1.分數 from B B1 where(select count(1) from B where 科目=B1.科目 and 分數〉=B1.分數)〈=3 order by B1.科目,B1.分數;

⑤ 用一條SQL(Mysql)語句查詢出下表,有2個科目80分以上的人的名字和對應的科目名。

create table stu
(
[name] varchar(10),
[course] varchar(10),
[score] int,
);

insert into stu values('tom','x',80);
insert into stu values('tom','y',75);
insert into stu values('tom','z',90);
insert into stu values('li','x',90);
insert into stu values('li','y',60);
insert into stu values('wang','x',80);
insert into stu values('wang','z',90);

select * from stu;

select b.* from
(select name,count(name) as c from stu where score>=80 group by name) as a,stu b
where a.name=b.name and a.c>=2 and b.score>=80;

⑥ access的SQL語句,寫一個能篩選出最受歡迎的人的語句

可以把同一個教師,不同科目的好評分開。如果不分開,把中間的科目名全部去掉就行了。
select N.科目名,N.教師ID, N.教師姓名,M.HPL from
(select max(e.b/f.a) AS HPL
from ((select 科目名,教師ID, 教師姓名, count(*) as b from table where hp=-1 group by 科目名,教師ID, 教師姓名)e
left join
(select 科目名,教師ID, 教師姓名, count(*) as a from table group by 科目名,教師ID, 教師姓名)f
on f.科目名=e.科目名 and f.教師ID=e.教師ID and e.教師姓名=f.教師姓名 )
) M
left join
(select e.科目名,e.教師ID, e.教師姓名,e.b/f.a AS HPL
from ((select 科目名,教師ID, 教師姓名, count(*) as b from table where hp=-1 group by 科目名,教師ID, 教師姓名)e
left join
(select 科目名,教師ID, 教師姓名, count(*) as a from table group by 科目名,教師ID, 教師姓名)f
on f.科目名=e.科目名 and f.教師ID=e.教師ID and e.教師姓名=f.教師姓名 )
) N
ON N.HPL=M.HPL
如果需要第個科目最受歡迎的教師,
select N.科目名,N.教師ID, N.教師姓名,M.HPL from
(select e.科目名,max(e.b/f.a) AS HPL
from ((select 科目名,教師ID, 教師姓名, count(*) as b from table where hp=-1 group by 科目名,教師ID, 教師姓名)e
left join
(select 科目名,教師ID, 教師姓名, count(*) as a from table group by 科目名,教師ID, 教師姓名)f
on f.科目名=e.科目名 and f.教師ID=e.教師ID and e.教師姓名=f.教師姓名 )
gropy by e.科目名
) M
left join
(select e.科目名,e.教師ID, e.教師姓名,e.b/f.a AS HPL
from ((select 科目名,教師ID, 教師姓名, count(*) as b from table where hp=-1 group by 科目名,教師ID, 教師姓名)e
left join
(select 科目名,教師ID, 教師姓名, count(*) as a from table group by 科目名,教師ID, 教師姓名)f
on f.科目名=e.科目名 and f.教師ID=e.教師ID and e.教師姓名=f.教師姓名 )
) N
ON N.HPL=M.HPL

⑦ sql查詢結果篩選

select id,max(user time)
from x
group by id
user time 為時間類型才有效

⑧ 在SQL Server資料庫中,查一個人同時至少選擇兩種科目的學號應該怎麼寫啊

大概引用樓上的樓上的:

科目表: sid name;
個人信息表: tid name ;
成績表: id score sid tid;

SELECT tid as 學號, COUNT(sid) AS 科目數 FROM 成績表 GROUP BY tid HAVING COUNT(sid) >= 2

⑨ 怎麼用SQL查詢結果的會計科目 顯示包括上級科目名稱

欄位裡面添加子查詢獲取上級科目,再用concat函數拼接自己的會計科目,整個查詢sql應該是select id,concat((select name from 表名 where id = left(a.id)limit 1),「\」,a.name) from 表名 a。

⑩ sql 按科目查詢查詢

CREATE TABLE [Test] (

[id] [int] IDENTITY (1, 1) NOT NULL ,

[name] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,

[subject] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,

[Source] [numeric](18, 0) NULL

) ON [PRIMARY]

GO

INSERT INTO [test] ([name],[subject],[Source]) values (N'張三',N'語文',60)

INSERT INTO [test] ([name],[subject],[Source]) values (N'李四',N'數學',70)

INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'英語',80)

INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'數學',75)

INSERT INTO [test] ([name],[subject],[Source]) values (N'王五',N'語文',57)

INSERT INTO [test] ([name],[subject],[Source]) values (N'李四',N'語文',80)

INSERT INTO [test] ([name],[subject],[Source]) values (N'張三',N'英語',100)

Go

交叉表語句的實現:

--用於:交叉表的列數是確定的

select name,sum(case subject when '數學' then source else 0 end) as '數學',

sum(case subject when '英語' then source else 0 end) as '英語',

sum(case subject when '語文' then source else 0 end) as '語文'

from test

group by name