logo

Back to questions

Who Made Quota?

Easy

As a Data Analyst on the Sales Operations team, you are given a list of salespeoples' deals for the year, and the annual quota they need to hit.

Write a SQL query that outputs each employee id and whether they hit the quota or not ('yes' or 'no'). Order the results by employee id in ascending order.

Table:

Column NameType
employee_idinteger
deal_sizeinteger

Example Input:

employee_iddeal_size
101400000
101300000
201500000
301500000

Table:

Column NameType
employee_idinteger
quotainteger

Example Input:

employee_iddeal_size
101500000
201400000
301600000

Example Output:

employee_idmade_quota
101yes
201yes
301no

Explanation

101 had 700k in sales, beating their 500k quota. 201 had 500k in sales, beating their 400k quota. 301 had 500k in sales, but had a 600k quota, so they didn't hit their goal.

PostgreSQL 14

Refer friends to get bonus content & cool prizes.