Targets vs Actual Sales
MediumDescription
monthly_targets and the view v_monthly_sales cover different months. For every month in
either one, show month, target_amount, revenue and result, using the first rule that applies:
no targetwhen the month has no targetno saleswhen the month has no salesmetwhen revenue is at least the targetmissedotherwise
End your query with ORDER BY month.
Tables
| monthly_targets |
|---|
| month (PK) |
| target_amount |
| v_monthly_sales |
|---|
| month |
| revenue |