Uploaded by هشام بركات الثانوية بنات

New Microsoft Word Document

advertisement
‫‪.‬‬
‫‪.‬‬
‫‪c-b‬روحــــك ‪ ..‬وارقصي‬
‫‪...‬‬
‫‪ talk you‬عاصمه اليابان‬
‫‪...‬‬
‫‪ Our‬الكوسه كويس‬
‫‪...‬‬
‫‪ Attack‬العيب و أزح‬
‫‪...‬‬
‫‪ Miss you‬وثابوني لوحدي‬
‫‪...‬‬
‫‪ so what to‬عليك يا بعيد‬
‫‪...‬‬
‫‪ OLD‬قبل كده ومحدش سمع الكالم‬
‫‪...‬‬
‫‪ Under‬ابن شداد‬
‫‪...‬‬
‫‪ web cam‬كيلو البطاطا النهاردة ؟؟‬
‫‪...‬‬
‫‪ as for‬في اليد خيرا ً من ‪ 10‬علي الشجره‬
‫‪...‬‬
‫‪ Post‬ايد امك النهاردة‬
‫‪...‬‬
‫‪ the body‬خالط‬
‫‪...‬‬
‫‪ Back Car‬و رشيدة‬
‫‪...‬‬
‫‪ Tomorrow‬بى أى حاجة‬
‫‪...‬‬
‫‪ Kiss‬بالستيك‬
‫‪...‬‬
‫‪ Both‬الواوا‬
‫‪...‬‬
‫‪ In tag‬حربى‬
‫‪...‬‬
‫‪ marry me‬علي األرض‬
Problem (1)
Write the Query
• Problem:
-Create a list of all tables whose first two characters in the
name of the table is JO
-The tables must be owned by the current Oracle User
• Tables Used:
-User_tables
Query
SELECT
table_name, owner
FROM
all_tables
WHERE
table_name LIKE'JO%';
Problem (2)
Create a list that includes the first initial of every employee's first name,
A space, and the last name
of the employee
• Tables Used:
- Employees
Query:
SELECT SUBSTR(first_name,1,1) || ' ' || last_name
FROM Employees;
Problem (3)
- Create a list of every employee's first name concatenated to a space and the
employee's last name, and the email of all employees where the email address
contains the string 'IN'
• Tables Used:
- Employees
Query:
SELECT first_name ||' ' || last_name, email
FROM Employees
WHERE email LIKE'%IN%';
Problem (4)
- Create a list of 'smallest' last name and the 'highest' last name from the
employees table
• Tables Used:
- Employees
Query:
SELECT last_name AS "First Last Name", last_name AS "Last Last Name"
FROM Employees
ORDER BY "First Last Name"
ASC, "Last Last Name" DESC;
Problem (5)
- Create a list of weekly salaries from the employees table where the weekly
salary is between 700 and 3000
- The salaries should be formatted to include a $- sign and have two decimal
points like: $9999.99
• Tables Used:
- Employees
Query:
SELECT TO_CHAR (ROUND (salary/4,2), 'fm$99,999.00') AS "Weekly Salary"
FROM Employees
WHERE salary BETWEEN 700 AND 3000;
Problem (6)
- Create a list of every employee and his related job title sorted by job_title
• Tables Used:
- Employees, Jobs
Query:
SELECT SUBSTR(employees.first_name,1,1) || ' ' || employees.last_name "Employee
Name", jobs.job_title "Jobs"
FROM Employees, Jobs
WHERE employees.job_id = jobs.job_id;
Problem (7)
-Create a list of every employee’s job, the salary ranges within the job, and the
employee's salary
-List the lowest and highest salary range within each job with a dash to
separate the salaries like this: 100 – 200
• Tables Used:
-Employees, Jobs
Query:
SELECT SUBSTR (employees.first_name,1,1) || ' ' || employees.last_name
"Employee Name", jobs.job_title "Jobs", MIN_SALARY ||'-'|| MAX_SALARY "Salary
Range", employees.salary "Employee's Salary"
FROM Employees, Jobs
WHERE employees.job_id = jobs.job_id;
Problem (8)
- Using an ANSII join method, create a list of every employee's first
initial and last name, and department name
- Make sure the tables are joined on all of the foreign keys declared between
the two tables
• Tables Used:
- Employees, Departments
Query:
SELECT SUBSTR(first_name,1,1) || ' ' || last_name "Employee Name",
department_name
FROM Employees NATURAL JOIN Departments;
Problem (9)
- Change the previous listing to join only on the department_id column
• Tables Used:
- Employees, Departments
Query:
SELECT SUBSTR (first_name,1,1) || ' ' || last_name "Employee Name",
department_name "Department Name"
FROM Employees e JOIN Departments d
ON (e.department_id = d.department_id);
Problem (10)
- Create a list of every employee's last name, and the word nobody or
somebody depending on whether or not the employee has a manager
- Use the Oracle DECODE function to create the list
• Tables Used:
- Employees
Query:
SELECT DECODE (manager_id, null,'Nobody','Somebody') "Works For", last_name
"Last Name"
FROM Employees;
Problem (11)
- Create a list of every employee's first initial and last name, salary, and a yes
or no to show whether or not an employee makes acommission
- Fix this query to produce the result.
Query:
SELECT SUBSTR(first_name,1,1)||' '|| last_name "Employee
"Salary", DECODE (commission_pct,null,'No','Yes') commission
FROM Employees;
Name",
salary
Problem (12)
- Create a list of every employee's last name, department name, city, and
state_province
- Include departments without employees
- An outer join is required
• Tables Used:
- Employees, Departments, Locations
Query:
SELECT E.last_name, D.department_name, L.city, L.state_province
FROM Employees E JOIN Departments D
ON E.department_id=D.department_id JOIN Locations L ON D.Location_id =
L.Location_id;
Download