⑴ sql 只有出生日期 如何統計出相同年齡人數 給我具體語句
假如統計1990-5-5相同年齡的人,主鍵為ID,生日的欄位為Birthday SQL語句: SELECT COUNT(ID) FROM 表名 WHERE Birthday BETWEEN '1990-1-1 00:00:00' AND '1990-12-31:23:59:59'
麻煩採納,謝謝!
⑵ sql實現相同年齡學生姓名的查詢
假定數據表A, 含欄位名學生姓名 NAME, 年齡 AGE, 查詢變數$ag;
select * from A where AGE=$ag;
⑶ SQL 只有出生日期 如何統計出相同年齡人數
只提供下思路: 1.使用函數獲得當天所在的年份,然後當年年份-出生年份=歲數,對相同的歲數進行統計分組 2.對出生年月的列進行分組,使得同年的分到一組,人後使用查詢語句統計各分組的人數 【酷_酷_幣】為您服務...
⑷ 在SQL中查詢年紀一樣大(出生年份一樣)的兩個不同學生的姓名,以及他們的年齡
--好歹給張表的截圖啊
--創建student表
create table student
( s_id number
,s_name varchar2(20)
,s_birthday date
)
--導入三組數據
insert into student values('001','liuzhao',to_date('1992-04-02 01:01:01','yyyy-mm-dd hh:mi:ss'));
insert into student values('002','lisi',to_date('1992-04-02 01:01:01','yyyy-mm-dd hh:mi:ss'));
insert into student values('003','wangwu',to_date('1990-02-10 01:01:01','yyyy-mm-dd hh:mi:ss'))
--查詢出生年份相同的學生姓名和年齡
select s_name ,to_number(to_char(sysdate,'yyyy'))-to_number(to_char(s_birthday,'yyyy')) age
from student
where to_char(s_birthday,'yyyy') in
(select to_char(s_birthday,'yyyy')
from student
group by to_char(s_birthday,'yyyy')
having count(1)>1)
⑸ SQL 查詢所有相同年齡的學生信息,並按年齡排序。
這樣吧
select*from學生基本檔案where年齡in(select年齡from學生基本檔案groupby年齡havingcount(*)>1)
⑹ SQL 只有出生日期 如何統計出相同年齡人數 給我具體語句
假如統計1990-5-5相同年齡的人,主鍵為ID,生日的欄位為Birthday
SQL語句:
SELECT COUNT(ID)
FROM 表名
WHERE Birthday BETWEEN '1990-1-1 00:00:00' AND '1990-12-31:23:59:59'
⑺ 查詢哪些學生的年齡相同的sql查詢代碼是什麼
select * from 表 where 年齡=。。
⑻ SQL語句 查詢與劉晨年齡相同的學生姓名
select 姓名 from 表 where 年齡= (select 年齡 from 表 where 姓名='劉晨')
關於subquery的詳細信息, 請參考以下鏈接:
https://technet.microsoft.com/en-us/library/ms189575(v=sql.105).aspx
⑼ SQL 只有出生日期 如何統計出相同年齡人數
例:表 tab1 ,出生日期欄位為 rq,sql語句如下
selecta.age,count(*)from
(selectyear(getdate())-year(rq)as"age"fromtab1)a
groupbya.age;
關鍵語句:select year(getdate()) - year(rq) as "age" from tab1
year函數獲取系統日期與出生日期的年份,將年份相減即年齡,當然也可以根據需求,取出月份,進行運算,獲得更精確的周歲。
⑽ 用SQL怎樣查詢同系、同年齡、同性別的學生啊
Select *
from Student T
Where T.sdept IN( Select sdept
From student S
Where S.sno<>T.sno and
T.sage IN ( Select sage
From student X
Where S.sno=X.sno and X.sno<>T.sno and
T.ssex IN ( Select ssex
From student Y
Where X.sno=Y.sno and Y.sno<>T.sno
)));