『壹』 sql語句列出成績在80分到100分之間的學生名單
select * from 學生表 where 學生表主鍵id in (select 學生表學生id from 成績表 where 成績欄位 between 80 and 100)
或
select * from 學生表 where 學生表主鍵id in (select 學生表學生id from 成績表 where 成績欄位>=80 and 成績欄位<=100)
『貳』 sql動態鏈接查詢列出某個同學某學期的所有成績
@con nvarchar(50) 你這個長度設置的太短了吧,你看你單引號里那一堆,何止50個字元,把長度加到2000吧
declare
@con nvarchar(2000),
@personname nvarchar(50),
@personterm int
select @con='select sc.courseid,ce.name,sc.grade from course ce,score sc,student st
where st.no=sc.no and ce.id=sc.courseid and ce.term=sc.term and st.name =@personname and sc.term =@personterm'
set @personname='張雲飛'
set @personterm=1
exec sp_executesql @con,N'@personname nvarchar(50),@personterm int',@personname,@personterm
『叄』 sql表中已知學生的姓名與成績,列出學生的姓名與學習情況
可以用select case實現:
select case when 成績>=85 then '好'
when 成績>=70 and 成績<84 then '良'
when 成績>=60 and 成績<69 then '中'
when 成績<60 then '差'
end 學習情況
from 表名
『肆』 在SQL中, 我想把某幾個人的所有成績列出來在一個表裡,並把個人單科成績排序。
其實沒必要用union,你試試這個
select dbo.Student.SNAME, dbo.Class.CNAME, dbo.Class.TEACHER, dbo.StudentClass.GRADE
FROM dbo.Class
INNER JOIN dbo.StudentClass ON dbo.Class.CNO = dbo.StudentClass.CNO
INNER JOIn dbo.Student ON dbo.StudentClass.SNO = dbo.Student.SNO
where SNAME in ('廖風' ,'周清') order by SNAME,GRADE desc
『伍』 sql如何統計全部學生的分數
---第個學員的成績
select 學號,名稱, isnull(語文,0) + isnull(數學,0) + isnull(英語,0) 總成績 from a left join b on a.學號=b.學號
--各科總成績
select sum(語文),sum(數學),sum(英語) from b
--總成績
select sum(語文)+sum(數學)+sum(英語) from b
『陸』 怎麼用SQL的查詢語句列出某同學所有課程的課程名和成績啊,並按成績從低到高排序啊
1、打開Microsoft SQL Server 2012,選中需要查詢所有表的資料庫。
『柒』 用sql語句選擇所有男學列出所有學生的姓名,課程名和成績
select
姓名,課程名,成績
from
student,course,grade
where
student.學號=grade.學號
and
course.課程號=grade.課程號
另外建議你把欄位改成英文或者是拼音,這樣比較不容易出錯
因為你可以用select
xm
as
姓名,kcm
as
課程名,這樣的形式的
『捌』 sql查詢語句的問題,「列出成績大於90的所有學生的姓名、專業、課程名稱、成績」這條語句怎麼寫
可以參考下面的代碼:
select s.姓名, s.專業, sc.成績, c.課程名稱
from 學生基本情況表 s, 成績表 sc, 課程表 c
where s.學號 = sc.學號 and c.課程編號 = sc.課程編號
and sc.成績 > 90
(8)sql中把成績列出清單擴展閱讀:
sql語句
刪除列:
Alter table table_name drop column column_name--從表中刪除一列
添加主鍵:
Alter table tabname add primary key(col)
平均:
select avg(field1) as avgvalue from table1
最大:
select max(field1) as maxvalue from table1