-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQLQueryw3school.sql
48 lines (48 loc) · 1.75 KB
/
SQLQueryw3school.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
SELECT * FROM customer
/****************************************************************/
SELECT CustomerName,City
FROM customer
/**************************************************************/
SELECT Country FROM customer
SELECT DISTINCT Country From customer /*Remove duplicates*/
SELECT COUNT (DISTINCT Country) FROM customer;
/**********************************/
/*SELECT COUNT(*) AS DistinctCountries
FROM (SELECT DISTINCT Country FROM customer)*/
/***********************************************************/
SELECT * FROM customer
WHERE Country = 'Mexico';
/*********************************************************/
SELECT * FROM customer
WHERE CustomerID=1; /*WHERE CustomerID > 80;*/
/*******************************************************/
SELECT * FROM Products
ORDER BY Price;
/*****************************************************/
SELECT * FROM Products
ORDER BY Price DESC;
/***************************************************/
SELECT * FROM Products
ORDER BY ProductName;
/**************************************************/
SELECT * FROM Products
ORDER BY ProductName DESC; /*Alphabetically DESC*/
/*************************************************/
SELECT * FROM customer
ORDER BY Country, CustomerName;
/*************************************************/
SELECT * FROM customer
ORDER BY Country ASC, CustomerName DESC;
/*************************************************/
SELECT * FROM customer
WHERE Country = 'Germany'
AND City = 'Berlin'
AND PostalCode > 12000;
/*************************************************/
SELECT *
FROM customer
WHERE Country = 'Germany' OR Country = 'Spain';
/*************************************************/
SELECT * FROM customer
WHERE NOT Country = 'spain' AND NOT Country = 'Germany'
/*************************************************/