TASK 10 Queries with aggregates (Pt. 1) Flashcards

(4 cards)

1
Q

Find the longest time that an employee has been at the studio

A

SELECT MAX(years_employed) as Max_years_employed
FROM employees;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

For each role, find the average number of years employed by employees in that role

A

SELECT role, AVG(years_employed) as Average_years_employed
FROM employees
GROUP BY role;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Find the total number of employee years worked in each building

A

SELECT building, SUM(years_employed) as Total_years_employed
FROM employees
GROUP BY building;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Example

A

SELECT AGG_FUNC(column_or_expression) AS aggregate_description, …
FROM mytable
WHERE constraint_expression;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly