Creating Queries Flashcards
What does the ‘GROUP BY’ function do?
*If your attribute has more than one category you can use the group by function to help see it in a stacked (eg. stacked bar chart) format
What 4 SiGNAL operators are available?
- arithmetic
- comparison
- logical
- mapping
Explain Arithmetic
+ - * / %(modulo i.e remainder)
eg. SELECT discount / price * 100
FROM THIS_PROCESS
Explain Comparison
> < >= <= = <>(not equal to)
Explain Logical
AND , IN, NOT, OR
Explain Mapping
IF (returning value based on condition)
eg. SELECT IF (condition, then, else)
Explain ‘Order by’ function
Function to sort the result set according to sorting criteria
Example of the order by function
‘ORDER BY column number ASC/DESC
Explain ‘Limit’ function
Function to limit the number of records in the result set
Example of the ‘Limit’ function
LIMIT no. of entries you want
What is Alias with and example
Aliases help to give data/column headers a temporary name to make them easier to read.
SELECT expression AS [“ALIAS”]
e.g SELECT “Case ID” as “Customer ID” (on the table produced it will be labelled as customer ID)
What is a subquery
a query that is nested inside a SELECT statement, or inside another sub query
when is subqueries used?
when retrieving data on an event-level
What are 3 date functions
DATE_TRUNC
NOW()
DURATION
Explain DATE_TRUNC
limits time stamps to certain units of time by removing detail
eg. SELECT….
DATE_TRUNC (‘Month’, (SELECT(end_time))).
as ‘Month in 2017’
[created row called ‘Month in 2017’, where it produced dates that stayed as the first day on every month in 2017, with the month only changing]