Can you show me some examples how to use query?

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

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.