SQL: Using between, not and in operators to filter records
SQL Wildcard & Special Operator : Exercise-6 with Solution
Write a query to filter all those orders with all information which purchase amount value is within the range 500 and 4000 except those orders of purchase amount value 948.50 and 1983.43.
Sample table: orders
SELECT * FROM orders WHERE (purch_amt BETWEEN 500 AND 4000) AND NOT purch_amt IN(948.50,1983.43);
Output of the Query:
ord_no purch_amt ord_date customer_id salesman_id 70005 2400.60 2012-07-27 3007 5001 70003 2480.40 2012-10-10 3009 5003 70013 3045.60 2012-04-25 3002 5001
Pictorial presentation :
Contribute your code and comments through Disqus.
Previous: Write a SQL statement to find those salesmen with all information who get the commission within a range of 0.12 and 0.14.
Next: Write a SQL statement to find those salesmen with all other information and name started with any latter within 'A' and 'K'.
What is the difficulty level of this exercise?