Task 11 Queries with aggregates (Pt. 2) Flashcards

(3 cards)

1
Q

Find the number of Artists in the studio (without a HAVING clause)

A

SELECT role, COUNT(*) as Number_of_artists
FROM employees
WHERE role = “Artist”;

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

Find the number of Employees of each role in the studio

A

SELECT role, COUNT(*)
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 years employed by all Engineers

A

SELECT role, SUM(years_employed)
FROM employees
GROUP BY role
HAVING role = “Engineer”;

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