SQL語句select查詢學生表的性別,年齡,並將年齡改為出生日期的語句

時間 2021-07-13 09:11:51

1樓:

首先如果只知道年齡,可以得出出生年份,但是沒辦法直接得出準確的出生日期的。

查詢:select *** 性別,age 年齡 from student;

更新:update student s set s.age=2019-s.age

2樓:絕世彬彬

select dateadd(year,-20,getdate()) as 出生年

把你的年齡大小替代20得出出生年,不是很準確的年份,因為不考慮月份的存在

3樓:

年齡最多推算出生年份,沒法出來日期啊

4樓:匿名使用者

select 性別,年齡 from 學生表;

update 學生表 set 年齡 = date_format(date_sub(now(),interval 年齡year),'%y%m%d');-- mysql

update 學生表 set 年齡 = to_char(add_months(sysdate,-12*年齡),'yyyymmdd') ;-- oracle

1 設計一個sql語句,顯示學生表中年齡最大的學生的姓名、性別和出生日期。

5樓:

1.select 姓名,性別,出生日期 from 學生表 where 出生日期=(select max(出生日期) from 學生表)

2.select 學號,課程編號,考試成績 from 成績表 a where 考試成績=

(select max(考試成績) from 成績表 b where b.學號=a.學號 and b.課程編號=a.課程編號)

6樓:情又獨中

1 select 姓名,性別,出生日期 from 學生表 a where age in (select max(age) from 學生表 b)

2 select 學號,課程編號,考試成績 from 成績表 where (課程編號,考試成績) in

(select 課程編號,max(考試成績) from 成績表 group by 課程編號)

7樓:匿名使用者

最好把具體的表附上。

1.如果就一張學生表,其中含有你想要的所有欄位。例如:student(name,gender,birth,age)

select name,gender,birth from student where age=(select max(age) from student)

2.應該有一個考試成績表,裡面有課程編號,學號和成績。例如:exam(studentid,score,classid)

select studentid,classid,max(score) from exam group by classid

sql語句:先按性別,性別相同再按年齡升序排序並輸出學生的姓名,性別和年齡資訊

8樓:匿名使用者

select 姓名,性別,year(date())-year(出生日期) from 表名 order by 性別 asc,year(date())-year(出生日期) asc

還是我來答吧

9樓:匿名使用者

select 姓名,性別,年齡 from 表名 order by 性別,年齡

10樓:匿名使用者

select name,***,age from tb_info order by ***,age esc

sql語句:表中記錄的資料有學生姓名,性別,出生年月,但是查詢要求的是姓名,性別和年齡,應該怎麼寫?

11樓:匿名使用者

什麼資料庫,不同資料庫算年齡的寫法不一樣

sql語句,檢索xx同學的學號,姓名和年齡,就是用查詢語句select……什麼什麼的嗎?能不能寫一

12樓:匿名使用者

如果有年齡欄位的bai話:du

select 學號,姓名,年齡 from 表名 where 姓名='xx'

如果沒zhi有年齡欄位,

dao但是有出

內生日期欄位的話

:容select 學號,姓名,year(getdate())-year(出生日期) as 年齡 from 表名 where 姓名='xx'

以上寫法sqlserver的,其他資料庫另外說明。

sql語句,已建立學生表(學號,姓名,性別,專業,出生日期,高考分數)和成績表(課程號,學號,成績

13樓:落月

1.查詢全體男學bai生情況,要求du結果按出生日zhi

期降序排列。dao

select * from 學生表回 where 性別='男' order by 出生日期答 desc

2.從學生表和成績表兩個表中,檢索所有成績多於85分的學號、姓名、課程號、學期和成績。

select a.學號,a.姓名,b.課程號,b.學期,b.成績 from 學生表 a join 成績表 b on a.學號=b.學號 where 成績》85

3.統計每個專業的學生人數

select 專業,count(*) as 學生人數 from 學生表 group by 專業

4.檢索出哪些至少有一門課程不及格學生的學號、姓名和專業。

select 學號,姓名,專業 from 學生表 where 學號 in (select distinct 學號 from 成績表 where 成績<60)

14樓:海螺的神器

1.查詢全體男學生情況,要求結果按出生日期降序排列。

select * from 學生表 s

left join 成績表 c on s.學號

回=c.學號

where s.性別='男' order by s.出生答日期 desc

2.從學生表和成績表兩個表中,檢索所有成績多於85分的學號、姓名、課程號、學期和成績。

select s.學號,s.姓名,c.課程號,c.學期,c.成績 from 學生表 s

left join 成績表 c on s.學號=c.學號

where c.成績》=85

3.統計每個專業的學生人數

select s.專業,count(*) from 學生表 s group by s.專業

4.檢索出哪些至少有一門課程不及格學生的學號、姓名和專業。

select s.學號,s.姓名,s.專業 from 學生表 s

where exists (

select 1 from 成績表 c where s.學號=c.學號

and c.成績<60 )

sql查詢命令實現以下。1.查閱學生表student中學生的學號,姓名和出生日期,結果年齡從大到小

15樓:

--第一題來

select 學號

源bai,姓名,出生du日期zhi from student order by 出生日期

--第二題

select a.學號,a.姓名 from student a inner join score b on a.學號=b.學號

where b.課程編號dao='0101' and b.成績>=90

sql查詢語句select中帶有casewhen巢狀子查詢判斷

1 建立兩張測試表 create table test case1 id number,value varchar2 200 create table test case2 id number,value varchar2 200 2 先在表1中插入測試資料 insert into test cas...

sql基礎查詢語句,sql簡單查詢語句

greate table insert selce filetad,name,calss,form student sql簡單查詢語句 1 首先開啟資料庫,建立好表。2 然後查詢全體教師的教師號 姓名 職稱,並分別為三列指定別名 教師號 姓名 職稱,如下圖所示。3 查詢結果如下圖所示。4 接著查詢所...

sql語句的select語句中用於實現選擇運算的子句是什麼

刺友互 1 select distinct 列名稱 from 表名稱,為student表內容。2 查詢名叫李四的學生值顯示一次,select distinct name from student。3 根據age排序,select distinct name from student order by...