Join targets with employee data, filter active employees, and calculate attainment
I need an attainment report before the QBR tomorrow. For every active sales rep, show me their name, year, quarter, target, actual, and attainment percentage. Sort by year and quarter. A couple things to watch: one of our reps is no longer with us but is still in the system — make sure they're excluded. Also Q4 2025 targets haven't been finalized yet so NULLs there are expected.
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN dim_employees to fact_targets on employee_id, and filter WHERE is_active = 1
Attainment = actual_amount / target_amount — use ROUND(..., 2) for clean output
NULL actual_amount values (Q4 2025) will make attainment NULL too — that's fine, don't filter them out