[Day8]Where子句实作

  1. 在HR的EMPLOYEES资料表中,查询2003年6月17日到职的员工姓名及工作部门代码。
SELECT first_name, last_name, department_id
FROM employees
WHERE hire_date='17-06月-2003'

https://ithelp.ithome.com.tw/upload/images/20210923/20140915zanVVB6zZB.png
2. 在HR的EMPLOYEES资料表中,查询薪水介於11000与12000之间的员工姓名、工作部门代码及到职日。

SELECT first_name, last_name, salary, department_id, hire_date
FROM employees
WHERE salary BETWEEN 11000 AND 12000;

https://ithelp.ithome.com.tw/upload/images/20210923/20140915zPO4yBC6W4.png
3. 在HR的EMPLOYEES资料表中,查询薪水大於等於8000的员工姓名、工作部门代码及到职日。

SELECT first_name, last_name, salary, department_id, hire_date
FROM employees
WHERE salary>=8000;

https://ithelp.ithome.com.tw/upload/images/20210923/20140915TclORCnF1u.png
4. 在HR的EMPLOYEES资料表中,查询主管编号为101或114,且任职於100号或110号部门的员工姓名、主管编号、工作部门代码及到职日。

SELECT first_name, last_name, manager_id, department_id, hire_date
FROM employees
WHERE manager_id IN(101,114)AND department_id IN(100,110);

https://ithelp.ithome.com.tw/upload/images/20210923/20140915utEaRrWHq2.png
5. 在HR的EMPLOYEES资料表中,职务名称中有CLERK或MAN,部门代码为30,薪水大於3000的员工编号、名字及薪水。

SELECT employee_id, first_name, salary
FROM employees
WHERE(job_id LIKE ‘%MAN’ OR job_id like’%CLERK’)
AND department_id=30
AND salary>3000;

https://ithelp.ithome.com.tw/upload/images/20210923/20140915V1E5YHEZBK.png
6. 查询OE帐户中的production_information 资料表中,哪些产品定价还未被输入。

  • 请注意:判断是否为空值需输入:WHERE 栏位 IS NULL;
    而不是WHERE 栏位 =NULL;
SELECT product_name, list_price
FROM product_information
WHERE list_price IS NULL;

https://ithelp.ithome.com.tw/upload/images/20210923/20140915Ytu6YMuVxV.png
7. 在HR的EMPLOYEES资料表中,薪水>=3000的员工姓氏、薪水及到职日,并依序以薪水和年资升幂排序。

  • 请注意:到职日需使用降幂排序(离目前日期越远越资深),年资才会由小到大显示。
SELECT last_name, salary, hire_date
FROM employees
WHERE salary>=3000
ORDER BY salary, hire_date DESC;

https://ithelp.ithome.com.tw/upload/images/20210923/20140915YoCMYpLQeR.png


<<:  Day8 PHP数据类型

>>:  Day07:Boardcast Event(推播事件)

[Day27] Flutter with GetX connectivity

connectivity侦测网路状态 判断当前是Wifi或是一般手机网路 在connectivity...

D30 - 如何看自己需要哪篇 Apps Script 的功能?三十天 Apps Script 旅程的总整理

大家好,今天就是我们铁人赛的最後一天了,想要在今天帮大家做个整理表,这样也比较好找资料。如果有兴趣,...

数据分析的好夥伴 - Python基础:档案读写

档案的读写算是Python非常实用的一环,可以帮助我们去编辑、储存或是新增建立一个档案。 在Pyrh...

第二十天:Gradle task graph

Gradle 的其中一个强大特点,就是它了解任务间的相依性,可以在核心建立出图或树。这对於开发者来说...

纵深防御(Defense in depth)

-NIST SP 800-160 V1和ISO 15288 NIST SP 800-160 V1强...