Download presentation
Presentation is loading. Please wait.
1
Pengenalan Basis Data Perintah Dasar SQL
Soal Minggu 1 Pengenalan Basis Data Perintah Dasar SQL
2
1. Evaluate this SQL statement :
SELECT c.customer_id, o.order_id, o.order_date, p.product_name FROM customer c, curr_order o, product p WHERE customer.customer_id = curr_order. customer_id AND o.product_id = p.product_id ORDER BY o.order_amount; This statement fails when executed. Which change will correct the problem? Use the table name in the ORDER BY clause. Remove the table aliases from the WHERE clause. Include the ORDER_AMOUNT column in the SELECT list. Use the table aliases instead of the table names in the WHERE clause. Remove the table alias from the ORDER BY clauses and use only the column name.
3
which statements produces the required result ?
2. Seniority is based on the number of years a student has been enrolled at the university. You must create a report that displays each student’s name, id number, and the number of years enrolled. The years enrolled must be rounded to a whole number, based on the number of months from the date enrolled until today. which statements produces the required result ? SELECT first_name||’,’||last_name “Student Name, id ”id”, enroll_date, TRUNC(SYSDATE,’YY’) – TRUNC(enroll_date,’YY’) “Seniority” FROM student; c SELECT first_name||’,’||last_name “Student Name, id ”id”, enroll_date, ROUND(MONTHS_BETWEEN(SYSDATE,enroll_date)/12) “Seniority” FROM student d SELECT first_name||’,’||last_name “Student Name”, id ”id”, enroll_date, ROUND(SYSDATE) – ROUND(enroll_date) “Seniority” e SELECT first_name||’,’||last_name “Student Name, id ”id”, enroll_date, (ROUND((SYSDATE) – ROUND(enroll_date)) /12 “Seniority” FROM student
4
3. The EVENT table contains these columns: EVENT_ID NUMBER
EVENT_NAME VARCHAR2(30) EVENT_DESC VARCHAR2(100) EVENT_TYPE NUMBER LOCATION_ID NUMBER You have been asked to provide a report of the number of different event types at each location. Which SELECT statement will produce the desired result? SELECT UNIQUE(location_id), COUNT(event_type) FROM event GROUP BY location_id; SELECT location_id, COUNT(DISTINCT event_type) FROM event GROUP BY location_id; SELECT location_id, MAX(DISTINCT event_type) FROM event GROUP BY location_id SELECT DISTINCT(event_type) FROM event GROUP BY location_id; SELECT COUNT(*), DISTINCT(location_id) FROM event;
5
4. Evaluate this SQL statement:
SELECT supplier_id, AVG(cost) FROM product WHERE AVG(list_price) > 60.00 GROUP BY supplier_id ORDER BY AVG(cost) DESC; Which clause will cause an error? SELECT ORDER BY WHERE GROUP BY
6
5. Which statement type would be used to remove transactions more than one year old from the TRX table ? DCL DDL DML DRL TCL
7
6. Which Database Objects not incluided in a Oracle Database
Table Sequence Constraint Synonym Index
8
7. Evaluate this SQL statement :
SELECT c.customer_id, o.order_id, o.order_date, p.product_name FROM customers c, curr_order o, product p WHERE customer.customer_id = curr_order. customer_id AND o.product_id = p.product_id ORDER BY o.order_amount; This statement fails when executed. Which changne will corect the problem? Use the table name in the ORDER BY clause Remove the table aliases from the WHERE clause Include the ORDER_AMOUNT column in the SELECT list. Use the table aliases instead of the table names in the WHERE clause Remove the table alias from the ORDER BY clauses and use only the column name
9
8. The EVENT table contains these columns:
EVENT_ID NUMBER EVENT_NAME VARCHAR2(30) EVENT_DESC VARCHAR2(100) EVENT_TYPE NUMBER LOCATION_ID NUMBER You have been asked to provide a report of the number of different event types at each location. Which SELECT statement will produce the desired result? SELECT UNIQUE(location_id), COUNT(event_type) FROM event GROUP BY location_id; SELECT COUNT(*), DISTINCT(location_id) FROM event; SELECT DISTINCT(event_type) FROM event GROUP BY location_id; SELECT location_id, COUNT(DISTINCT event_type) FROM event GROUP BY location_id; SELECT location_id, MAX(DISTINCT event_type) FROM event GROUP BY location_id;
10
9. Evaluate this SQL statement
SELECT supplier_id, AVG(cost) FROM product WHERE AVG(list_price) > 60.00 GROUP BY supplier_id ORDER BY AVG(cost) DESC; Which clause will cause an error? SELECT WHERE GROUP BY ORDER BY
11
10. Evaluate this SELECT statement:
SELECT employee_id, name FROM employee WHERE employee_id NOT IN (SELECT employee_id FROM employee WHERE department_id = 30 AND job = ‘CLERK’); What would happen if the inner query returned a NULL values? A syntax error would be returned No rows would beselected from the employee tables All the EMPLOYEE_ID and NAME values in the EMPLOYEE table would be displayed Only the rows with EMPLOYEE_ID values equal to NULL would be included in the results
12
11. You query the database with the SELECT statement:
SELECT COUNT(instructor_id) FROM class; Which value is displayed? 2 3 4 5 The statement will NOT execute succesfully CLASS_ID CLASS_NAME HOURS_CREDIT INSTRUCTOR_ID 1 Intro. To Acc. 3 4 2 Computer Basic Tax Accounting American History 5 Basic Engineering
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.