Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

SQL Commands

Uploaded by

gmundluru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

SQL Commands

Uploaded by

gmundluru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Or / are :

SELECT * FROM Customers


WHERE City='Berlin' OR City='München';

SELECT * FROM Customers


WHERE Country='Germany' AND City='Berlin';

IN command:

SELECT * FROM Customers


WHERE Country IN ('Germany', 'France', 'UK');

Distinct & Count :

SELECT DISTINCT Country FROM Customers;


SELECT COUNT(DISTINCT Country) FROM Customers;

SELECT COUNT(*)
FROM Products;

NOT Operator:
SELECT * FROM Customers
WHERE NOT Country='Germany';

Null & not null

SELECT CustomerName, ContactName, Address


FROM Customers
WHERE Address IS NULL;

SELECT CustomerName, ContactName, Address


FROM Customers
WHERE Address IS NOT NULL;

SQL MIN() and MAX()


SELECT MIN(Price)
FROM Products;

Avg & sum

SELECT AVG(Price)
FROM Products;

SELECT SUM(Quantity)
FROM OrderDetails;
LIKE:
Customer name starting with ‘a’:

SELECT * FROM Customers


WHERE CustomerName LIKE 'a%';

Customer name ending with ‘a’:

SELECT * FROM Customers


WHERE CustomerName LIKE '%a';

Customer name any position with ‘or’:

SELECT * FROM Customers


WHERE CustomerName LIKE '%or%'

Selecting ‘r’ in the second position:

SELECT * FROM Customers


WHERE CustomerName LIKE '_r%';

Starting with ‘a’ and end with ‘o’:

SELECT * FROM Customers


WHERE ContactName LIKE 'a%o';

Name doesn’t start with ‘a’:

SELECT * FROM Customers


WHERE CustomerName NOT LIKE 'a%';

You might also like