-
-
Save jhyland87/aef54f22a2aae23d3f20bdb716d76431 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Table Name: Employee | |
Employee_id First_name Last_name Salary Joining_date Department Order | |
---------------------------------------------------------------------------------------------- | |
1 Roy Thomas 700000 01-FEB-13 12.00.00 AM Banking 3 | |
2 Michael Clarke 800000 01-JAN-13 12.00.00 AM Insurance 2 | |
3 John Abraham 1000000 01-JAN-13 12.00.00 AM Banking 5 | |
4 Tom Jose 600000 01-FEB-13 12.00.00 AM Insurance 4 | |
5 TestName1 123 650000 01-JAN-13 12.00.00 AM Services 1 | |
6 Philip Mathew 750000 01-JAN-13 12.00.00 AM Services 8 | |
7 Jerry Pinto 650000 01-FEB-13 12.00.00 AM Insurance 10 | |
8 TestName2 Lname% 600000 01-FEB-13 12.00.00 AM Insurance 6 | |
Table name: Incentives | |
Employee_ref_id Incentive_date Incentive_amount | |
-------------------------------------------------------- | |
1 01-FEB-13 5000 | |
2 01-FEB-13 3000 | |
3 01-FEB-13 4000 | |
1 01-JAN-13 4500 | |
2 01-JAN-13 3500 | |
Questions: | |
1) Generate a list of employees with a salary over $750,000 | |
Answer: select * from employess groupby(emp_sal) having on emp_sal>$75000 | |
2) Find any users who may have invalid names (only alphabetic chars and hyphens allowed) | |
Answer: Select id, Name from users where Name like[a-z][-] | |
3) Generate a list of employees in the Banking department, sort them by join date | |
Answer: select id,Name,joindate from employees where dept = bank Order by joindate ASC | |
4) Get the employees who all have incentive dates in Feburary | |
Answer: select * fom employees where incentive_date like "%Feb%" | |
5) Generate a list of usernames, making it the first initial and last name, in lower case format (example result: Roy Thomas = rthomas) | |
Answer: select TO_LOWER(concat(substring(firstname,1,1),lastname)) as username from employess; | |
6) Get a list of the employees, sort them (ascending) by the "order" column, only returning 4 rows | |
Answer: select * from employees where rownum <=4 | |
order by order asc | |
7) Generate a list of the 3 newest employees in the Banking department or Services department | |
Answer: select * from employees where rownum > 4 | |
order by joindate desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment