**Select all rows and columns where column A contains the name Jonatan:**

SELECT * WHERE A='Jonatan'

**Select all rows but only columns B and C where column A contains the name Carl:**

SELECT B,C WHERE A='Carl'

**Select all rows but only columns B and C where column A either contains the name Ted or Chad:**

SELECT B,C WHERE A='Ted' OR A='Chad'

**Select all rows but only columns B and C where column A contains the name George and column B the name Chad:**

SELECT B,C WHERE A='George' AND B='Chad'

**Select all rows but only columns B and C where column A contains the name George or Chad and column B a value that is bigger than 1000:**

SELECT B,C WHERE (A='George' OR A='Chad") AND (B>1000)

**Select the first 10 rows and columns B and C where column A contains the name George and column B the name Chad:**

SELECT B,C WHERE A='George' AND B='Chad' LIMIT 10

**Select all rows but only columns B and sort all rows by values found in column C in descending order:**

SELECT B,C ORDER BY C DESC

**Select all rows but only columns B and sort all rows by values found in column C in ascending order:**

SELECT B,C ORDER BY C ASC

**Select all rows but only columns B and the sum of C and D, and sort all rows by values found in column C in ascending order:**

SELECT B,C+D ORDER BY C ASC

**Select the first 10 rows but only columns B and C and sort those by values found in column C in ascending order:**

SELECT B,C ORDER BY C ASC LIMIT 10

**Group all values in column A and for each of the values, build the sum of column B, count how many entries found in B, build the average of column B, find the maximum value of column B, and the minimum value of B:**

SELECT A,SUM(B),COUNT(B),AVG(B),MAX(B),MIN(B) GROUP BY A

**Select all values in column A that contain gmail.com:**

SELECT A WHERE A CONTAINS 'gmail.com'

**Select all values in column A that don't contain gmail.com:**

SELECT A WHERE NOT A CONTAINS 'gmail.com'

**Select all rows from columns G, I, M and P that have a year greater than 2016 in column M:**

SELECT G,I,M,P WHERE YEAR(M) > 2016

## Comments

0 comments

Please sign in to leave a comment.