SQL: Using where clause with not operator and NULL
SQL Wildcard & Special Operator : Exercise-21 with Solution
Write a SQL statement to find that customer with all information who gets a grade except NULL value.
Sample table: customer
Sample Solution :
SELECT * FROM customer WHERE grade IS NOT NULL;
SELECT * FROM customer WHERE NOT grade IS NULL;
Output of the Query:
customer_id cust_name city grade salesman_id 3002 Nick Rimando New York 100 5001 3007 Brad Davis New York 200 5001 3005 Graham Zusi California 200 5002 3008 Julian Green London 300 5002 3004 Fabian Johnson Paris 300 5006 3009 Geoff Cameron Berlin 100 5003 3003 Jozy Altidor Moscow 200 5007
Pictorial presentation :
Query Visualization for Sample Solution:
Query Visualization for alternate Sample Solution:
Contribute your code and comments through Disqus.
Previous: Write a SQL statement to find that customer with all information who does not get any grade except NULL.
Next: Write a query in SQL to display all the data of employees whose last name begins with an 'D'.
What is the difficulty level of this exercise?