怎麼用SQL查詢在學生表中設定每個學生的年齡

2021-03-04 02:39:33 字數 3630 閱讀 9280

1樓:我的小名叫仙女

select top 3 * from student order by age asc

top 3 是前抄3個學生的意思, order by age asc 的意思是根

襲據年齡升序排列, 也就是說最前面的就是年齡最小的。 (當然你沒有考慮到的是3個最小的年齡一樣的話, 是不是還要加個條件, 比如學號, 性別)

2樓:書布凡邰黎

insert

into

學生資訊(欄位

baidu1,欄位2,……,欄位n)

values(欄位1的值zhi,欄位2的值,……,欄位n的值)如dao

insert

into

學生資訊版(學號,姓名,性別,班級,出生日期權)values('00001','李四','男','01班','01/01/2000')

mysql 資料庫題目 查詢student表中每個學生的姓名和年齡。

3樓:匿名使用者

select date_format(now(), '%y') - date_format(sbirthday, '%y') - (date_format(now(), '00-%m-%d')

< date_format(sbirthday, '00-%m-%d')) as age from student; 查出du

精確zhi

。。dao。。自己專

加名字屬

4樓:匿名使用者

select sname,datediff(year,sbirthday,getdate()) as nl

from student

getdate() --表示當

bai前時間du,zhi

daomysql當前時間是

回:now()還是getdate()?你試下答

5樓:匿名使用者

貌似oracle有一個months_between函式,可以直接用的。

急急急!!!怎麼用sql語句查詢student表中年齡最小的前三名學生資訊?

6樓:匿名使用者

select top 3 * from student order by age asc

top 3 是前3個學生的意思, order by age asc 的意思是根據年齡升序排列, 也就是說最前面的就是年齡最小的。 (當然你沒有考慮到的是3個最小的年齡一樣的話, 是不是還要加個條件, 比如學號, 性別)

7樓:匿名使用者

select top 3 * from student order by 年齡 asc

8樓:匿名使用者

hjghghgjhgjh

使用sql命令將學生表student中的學生年齡age欄位的值增加1歲,應該怎麼寫?

9樓:風音

update [student] set age = age + 1

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

10樓:

--第一題來

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語句表示:查詢每個班級的學生人數

11樓:足壇風行者

查詢每個班級的bai學生人數

du的sql語句是:

select class_name,count(1) from table_name group by class;

其中class_name,count(1)為查出的班級zhi名和對應的人dao數,table_name為學回生表名稱,group by是將class分組。

擴充套件資

答料

sql語句中group by 語句用法介紹:

group by 語句用於結合聚合函式,根據一個或多個列對結果集進行分組。語法格式為:

select column_name, aggregate_function(column_name)

from table_name

group by column_name;

例如有以下表:

例項:select site_id, sum(access_log.count) as nums from access_log group by site_id;

執行以上 sql 輸出結果如下:

注意點:在select指定的欄位要麼就要包含在group by語句的後面,作為分組的依據;要麼就要被包含在聚合函式中。

12樓:用著追她

1、查詢表的指定列

copy,select 列名稱

from 表名稱。

2、查詢表的所有列,select * from 表名稱。

3、按條件查詢,select * from 表名稱 where 列=值。

4、多條件查詢,select * from 表名稱 where 列1=值1 and 列2=值2。

5、查詢年齡為100的學生名字,select `name` from student where age = 100 。

6、查詢趙六的年齡,select age from student where `name` = '趙六'。

13樓:匿名使用者

select 班級號,count(*) from 學生表 group by 班級號

不知道您的表是什麼樣的

14樓:匿名使用者

select 班級,count(1) as 人數 from 學生表 group by 班級

15樓:匿名使用者

例如來用源oracle資料庫

create table student(stuid number not null primary key,stuname varchar2(20) not null,stu*** char(2) not null,stuage number not null,classid number --班級編號) select count(*) from student group by classid

16樓:安徽新華電腦專修學院

school_name 學校名字抄

,襲major_name專業名字,majorcount專業數量,table_name表名

select school_name,major_name,count(majoy_name) as majorcount from table_name

group by school_name,major_name

sql,表與表之間列的包含查詢,sql中引用一個表的查詢結果作為條件來查詢另一個表如何實現?

具體什麼資料庫?最後你要的資料什麼樣子?sql語句如何模糊查詢兩個表中兩列的包含情況 50 select from 表名 where col1 like convert nvarchar,select col2 from dbo.userinfo where 條件 注意 因為 like 這裡面的模糊...

SQL怎麼查詢兩個表中不同的資料

我們需要準備的材料分別是 電腦 sql查詢器。1 首先,開啟sql查詢器,連線上相應的資料庫表,以查詢c1表和c2表的name欄位不同為例。2 點選 查詢 按鈕,輸入 select c1.name from c1 left join c2 on c1.name c2.name where c2.na...

sql根據欄位不同值查詢不同表中的欄位

select case role when 0 then select name from tablea where dd 11 else select name from tableb where dd 11 end as name from post 就是使用 case 我沒有實驗過。如果有心在...