⑴ 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
)));