SQL Key Words Flashcards
What will you use for getting special column from a table?
SELECT
FROM
How to tell SQL where the end of your query is?
;(semicolon)
If you want to return a certain number of results, what can you use?
LIMIT
If you want to select all the unique values from a column, what can you use?
If use Numpy, what can you use?
DISTINCT
numpy.unique(sequence)
If you want to know how many rows in a table, what can you use?
How many non-missing values in a column, what can you use?
COUNT(*)
COUNT()
If you want to filter based on both text and numeric values in a table, it is often with comparison operators and comes after the FROM, what can you use?
WHERE
In SQL, what can you use for not equal operator? As per the SQL standard.
<>
Which version of SQL you will use single quotes with WHERE, like ‘WHERE’?
PostgreSQL
Using IOS date format, what January 22th,2008 will be?
‘2008-01-22’
If you want to select data based on multiple conditions, what the keyword can you build up your WHERE queries by combining multiple conditions with?
AND
What will you need to specify separately for every AND condition?
the column name For example : SELECT title FROM films WHERE release_year > 1991 AND release_year < 2008
If you want to select rows that meet some but not all conditions, what will you use?
AND
OR
Displaying rows that meet one of the specified conditions, what can you use?
OR
What can you use alternatively like the following: SELECT * FROM people WHERE age >= 10 AND age <= 14;
SELECT *
FROM people
WHERE age
BETWEEN 10 AND 14;
Checking for range in SQL, what can you use?
It is not like range() in Python, cause it’s inclusive.
BETWEEN
If you want to filter based on many conditions making it easier and quicker to specify multiple OR conditions, what can you use with WHERE?
IN
In SQL, what represents a missing or unknown value?
NULL
What expression can you use for checking NULL values?
What about not missing values?
IS NULL
IS NOT NULL
To searching for a pattern in a column, what can you use in a WHERE clause?
LIKE
To searching for a pattern in a column, what wildcard will match 0,1,or many characters in text?
%
To searching for a pattern in a column, what wildcard will match a single character in text?
_
SQL provides a few functions to perform some calculation on the data in a database, what’s its name?
Aggregate functions
To get the average value from a column of table, what can you use?
AVG()
To get the highest value from a column of table, what can you use?
MAX()
To get the result of adding up the numeric values from a column of table, what can you use?
SUM()
Using aggregate functions, you can perform basic arithmetic with symbols, what are they?
+ - * /
To avoid using multiple same functions result, SQL allows you aliasing simply means you assign a temporary name to something. What can you use?
AS
Like ‘as’ keyword in Python:
import numpy as np
In SQL, if you want to sort results in ascending or descending order according to the values of one or more columns, what keyword can be used?
ORDER BY
By default ORDER BY will sort in ascending order. If you want to sort the results in descending order, what can you use?
DESC
ORDER BY can be used to sort on multiple columns. What is important using it?
The order of columns.
If you want to hybrid SELECT operation between string and numeric data type in SQL, what can you use?
GROUP BY
What keyword always goes after the FROM clause?
GROUP BY
When combining GROUP BY and ORDER BY. Make sure to always put the ORDER BY clause at the end of your query. Why ?
I can’t sort values that haven’t calculated yet!
If you want to filter based on the result of an aggregate function, what can you use?
HAVING