当前位置:首页>开发>正文

有关SQL的面试题。。。 sql语句的面试题求解答啊,一共三个表,悬赏100啊

2023-06-26 00:41:11 互联网 未知 开发

 有关SQL的面试题。。。 sql语句的面试题求解答啊,一共三个表,悬赏100啊

有关SQL的面试题。。。

1:
〔车辆〕、〔站台〕、〔行车路线〕最少3个表
〔车辆〕表字段〔ID〕,〔名称〕
〔站台〕表字段〔ID〕,〔名称〕,〔描述〕
〔行车路线〕表字段〔ID〕,〔车ID〕,〔站ID〕
查询:
SELECT 〔车辆〕.〔名称〕,〔站台〕.〔名称〕
FROM 〔车辆〕 INNER JOIN 〔行车路线〕
ON 〔车辆〕.〔ID〕=〔行车路线〕.〔车ID〕
INNER JOIN 〔站台〕
ON 〔站台〕.〔ID〕=〔行车路线〕.〔站ID〕
WHERE 〔站台〕.〔名称〕 = 车站1
OR 〔站台〕.〔名称〕 = 车站2

2:数据库设计
〔部门〕表:ID,父级ID,名称
〔员工〕表:ID,父级ID,名称,权限
〔员工所属部门〕表:ID,员工ID,部门ID
〔申请〕表:ID,内容,申请人ID,审核人ID,审核结果,备注

系统设计:
1 员工进入申请页面时,根据〔员工〕的权限来判断是否能进入
2 员工查询〔申请〕表,通过申请人ID过滤,只有申请权限
3 经理查询〔申请〕表,通过〔员工〕表查申请人的父级ID过滤,可以进行审批操作

sql语句的面试题求解答啊,一共三个表,悬赏100啊

1,select e_name from employee where e_hiredate>to_date(2001-01-01,YYYY-MM-dd) and
e_hiredate2,update employee set e_level=e_level 1,e_hiredate=sysdate where dept_id in(select dept_id from deptar where dept_name=监察部)

面试题目(sql)

我使用的是MySQL 如下语句:
建表语句:
create table Lessoninfo(
no int,
week int,
isonduty char)

插入数据:略
insert into Lessoninfo values(...............)

SQL查询语句:

select no as 教师号, sum(week=1) as 星期一,sum(week=2) as 星期二,sum(week=3) as 星期三 from Lessoninfo group by no

/***********************附结果******************

mysql> select no as 教师号, sum(week=1) as 星期一,sum(week=2) as 星期二,su
m(week=3) as 星期三 from Lessoninfo group by no
-------- -------- -------- --------
| 教师号 | 星期一 | 星期二 | 星期三 |
-------- -------- -------- --------
| 1 | 0 | 2 | 1 |
| 2 | 1 | 0 | 0 |
| 3 | 0 | 1 | 0 |
-------- -------- -------- --------
3 rows in set (0.02 sec)

Mysql 数据库面试问题

select
t1.non_seller,
t3.coupon,
ifnull(sum(t2.bal),0)
from
(select seller,coupon from
(select distinct seller from t2) c,
(select distinct coupon from t2) d
) t left join t2 on
t3.seller=t2.seller and t3.coupon=t2.coupon
join ton t1.seller=t3.seller
group by
t1.non_seller,t3.coupon
order by t3.coupon,t1.non_seller

SQL面试题

select year, (select sum(salary) from t_salary b where b.year <= a.year) salary from t_salary a
group by year

数据库SQL查询语句面试题

5.select a.username,b.deptname from users a,dept b where a.dept_id=b.id

5.update users set dept_id=9 where dept_id=2

5.select a.deptname,b.count_id from dept a,(select dept_id,count(id) as count_id from users group by dept_id having count(id)>1) b where a.id=b.dept_id

5.select a.deptname,b.count_man,c.count_woman from dept a,(select dept_id,count(sex) as count_man from users where sex=男 group by dept_id) b,(select dept_id,count(sex) as count_woman from users where sex=女 group by dept_id) c where a.id=b.dept_id and a.id=c.dept_id

5.添加历史记录表
create table history(
id number(8), -- 记录编号
dept_id varchar2(5), -- 部门ID
user_id varchar2(5), -- 用户ID
change_date date -- 变动日期
)

1.一道SQL语句面试题

SELECT the_date,
(SELECT COUNT(*) FROM T AS T1 WHERE T1.the_date=T.the_date AND T1.the_type=胜) AS 胜,
(SELECT COUNT(*) FROM T AS T1 WHERE T1.the_date=T.the_date AND T1.the_type=负) AS 负
FROM T GROUP BY the_date

最新文章

随便看看