【文章內(nèi)容簡(jiǎn)介】
ngrade bon = group by , 6. 使用UNION運(yùn)算符將student_info表中姓“劉”的學(xué)生的學(xué)號(hào)、姓名與姓“張”的學(xué)生的學(xué)號(hào)、姓名返回在一個(gè)表中,如圖41所示。圖 41select 學(xué)號(hào),姓名 from studentsdb .dbo .student_info where 姓名 like 39。劉%39。union allselect 學(xué)號(hào),姓名 from studentsdb .dbo .student_info where 姓名 like 39。張%7. 嵌套查詢(1) 在student_info表中查找與“劉衛(wèi)平”性別相同的所有學(xué)生的姓名、出生日期。select 姓名,出生日期 from studentsdb .dbo .student_info where 性別= (select 性別 from student_info where 姓名 =39。劉衛(wèi)平39。 )(2) 使用IN子查詢查找所修課程編號(hào)為0000005的學(xué)生學(xué)號(hào)、姓名、性別。select 學(xué)號(hào),姓名,性別 from studentsdb .dbo .student_info where 學(xué)號(hào) in(select 學(xué)號(hào) from grade where 課程編號(hào) =39。000239。 or 課程編號(hào) =39。000539。)(3) 列出學(xué)號(hào)為0001的學(xué)生的分?jǐn)?shù)比0002號(hào)的學(xué)生的最低分?jǐn)?shù)高的課程編號(hào)和分?jǐn)?shù)。select 課程編號(hào),分?jǐn)?shù) from grade where 學(xué)號(hào) =39。000139。and 分?jǐn)?shù) (select MIN (分?jǐn)?shù)) from grade where 學(xué)號(hào)=39。000239。)(4) 列出學(xué)號(hào)為0001的學(xué)生的分?jǐn)?shù)比0002的學(xué)生的最高成績(jī)還要高的課程編號(hào)和分?jǐn)?shù)。select 課程編號(hào),分?jǐn)?shù) from g