First mid term

advertisement

Kingdom of Saudi Arabia

Ministry of Higher Education

Majmaah University

College Of Sciences in Alzulfi

ميحرلا نمحرلا الله مسب

ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا

يـلاـعـلا مـيـلـعـتـلا

ةـعـمـجـمـلا

ةرازو

ةـعـماـج

يفلزلاب مولعلا ةيلك

سداسلا : ىوتسملا CIS326 : ةداملا زمرو مقر 2 تانايبلا دعاوق : ةداملا مسا

1435 / 12 / 28 : ناحتملإا خيرات : يعماجلا مقرلا : بلاطلا مسا

Question 1:

For table shown in Fig. 1 write the output for each of the following SQL statement:

EmployeeID LastName FirstName BirthDate

1 Davolio Nancy 1968-12-08

2 Fuller Andrew 1952-02-19

3 Leverling Janet 1963-08-30

4 Peacock Margaret 1958-09-19

7

8

5

6

Buchanan Steven

Suyama Michael

King Robert

Callahan Laura

Dodsworth Anne

West Adam

1955-03-04

1963-07-02

1960-05-29

1958-01-09

1969-07-02

1928-09-19

9

10

Fig. 1 a- SELECT firstname, lastname, NULLIF(LENGTH(firstname), LENGTH(lastname)) result

FROM employees

Where LENGTH(firstname) = LENGTH(lastname) b- SELECT Firstname, ROUND(BirthDate, 'MONTH') Date

FROM employees where birthdate like '%196%' order by birthdate

1

Kingdom of Saudi Arabia

Ministry of Higher Education

Majmaah University

College Of Sciences in Alzulfi

ميحرلا نمحرلا الله مسب

ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا

يـلاـعـلا مـيـلـعـتـلا

ةـعـمـجـمـلا

ةرازو

ةـعـماـج

يفلزلاب مولعلا ةيلك

سداسلا : ىوتسملا CIS326 : ةداملا زمرو مقر 2 تانايبلا دعاوق : ةداملا مسا

1435 / 12 / 28 : ناحتملإا خيرات : يعماجلا مقرلا : بلاطلا مسا

Question 2:

Fig. 2 a. What are the outputs after run the following queries on table in Fig.2 :

1- SELECT last_name

FROM employees

WHERE last_name LIKE '_o%';

2- SELECT departmnt_id, job_id

FROM employees

WHERE job_id LIKE '%IT\_%’ ;

3- SELECT last_name, job_id

FROM employees

WHERE job_id NOT IN ('IT_PROG', 'ST_CLERK', 'SA_REP');

2

Kingdom of Saudi Arabia

Ministry of Higher Education

Majmaah University

College Of Sciences in Alzulfi

ميحرلا نمحرلا الله مسب

ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا

يـلاـعـلا مـيـلـعـتـلا

ةـعـمـجـمـلا

ةرازو

ةـعـماـج

يفلزلاب مولعلا ةيلك

سداسلا : ىوتسملا CIS326 : ةداملا زمرو مقر 2 تانايبلا دعاوق : ةداملا مسا

1435 / 12 / 28 : ناحتملإا خيرات : يعماجلا مقرلا : بلاطلا مسا

4- SELECT employee_id, CONCAT(job_id, last_name) NAME,

LENGTH (last_name), INSTR(LOWER(last_name), ’m’) "Contains ’m’?"

FROM employees

WHERE SUBSTR(last_name, -1, 1) = ’t’; b. Fig. 2 is a result of running query on employee table. Write that query statement gives result in that order.

3

Download