0% found this document useful (0 votes)
17 views

Exercise 2: 1. First - Name John 2. Sales - Date Order - Id Product - Id Sales - Date JAN

The document contains 6 SQL queries to retrieve data from various tables based on different filtering criteria like amount, date, quantity, and color. It also contains 2 SQL statements that will result in errors and the corrections needed to fix those errors are provided. The corrections involve enclosing character and date values in single quotes.

Uploaded by

Karina Quispe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Exercise 2: 1. First - Name John 2. Sales - Date Order - Id Product - Id Sales - Date JAN

The document contains 6 SQL queries to retrieve data from various tables based on different filtering criteria like amount, date, quantity, and color. It also contains 2 SQL statements that will result in errors and the corrections needed to fix those errors are provided. The corrections involve enclosing character and date values in single quotes.

Uploaded by

Karina Quispe
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 2

1. Produce a list of rows showing all columns from the SALES table where total amount
greater than 1000.

2. Produce a list of rows showing all columns from the SALES table where total amount is
not equal to 44.

3. Produce a list of rows showing all columns from the SALES table where quantity is less
than or equal to 10.

4. Produce a list of rows showing all columns from the SALES table where sales date is equal
to 9th February 2015

5. Produce a list of rows showing all columns from the PRODUCT table where color is equal
to RED.

6. Produce a list of rows showing all columns from the SALES table where total amount is
greater than sales amount

Copy and paste the below SQL’s in SQL Developer and run
them, You will get errors and try to correct those errors.

1. SELECT * FROM CUSTOMER WHERE FIRST_NAME = JOHN

2. SELECT SALES_DATE, ORDER_ID, PRODUCT_ID FROM SALES


WHERE SALES_DATE = 01-JAN-2015
Answers:
1. SELECT * FROM sales WHERE total_amount > 1000;

2. SELECT * FROM sales WHERE total_amount != 44;

3. SELECT * FROM sales WHERE quantity <= 10;

4. SELECT * FROM sales WHERE sales_date = ’09-feb-2015’;

5. SELECT * FROM product WHERE color = ‘RED’;

6. SELECT * FROM sales WHERE total_amount > sales_amount;

Answers for errors:


1) You will get an error “ ORA-00904: "JOHN": invalid identifier ” when you run below SQL
statement.

SELECT * FROM CUSTOMER WHERE FIRST_NAME = JOHN

Correct the above SQL statement by enclosing JOHN in single quotations. Remember a
character value should be enclosed in single quotations.

SELECT * FROM CUSTOMER WHERE FIRST_NAME = 'JOHN'

2) You will get an error “ ORA-00904: "JAN": invalid identifier ” when you run below SQL
statement.

SELECT SALES_DATE, ORDER_ID, PRODUCT_ID FROM SALES


WHERE SALES_DATE = 01-JAN-2015

Correct the above SQL statement by enclosing 01-JAN-2015 in single quotations.


Remember a Date value should be enclosed in single quotations.

SELECT SALES_DATE, ORDER_ID, PRODUCT_ID FROM SALES


WHERE SALES_DATE = '01-JAN-2015'

You might also like