Jawaban Pembahasan Soal Sertivikasi 1 [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?

  1. Use the table name in the ORDER BY clause.
  2. Remove the table aliases from the WHERE clause.
  3. Include the ORDER_AMOUNT column in the SELECT list.
  4. Use the table aliases instead of the table names in the WHERE clause.
  5. Remove the table alias from the ORDER BY clauses and use only the column name.

Jawaban : D

Ketika melakukan join beberapa table yang banyak, sehingga memudahkan dan tidak ambigu. Karena alias pada WHERE salah, seharusnya WHERE c.customer_id = o.customer_id

Continue reading