Companies Above a Salary Threshold
Reported by candidates from Verisk's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The cutoff is 40000, and it's strictly greater than, not greater than or equal. That one detail decides whether you pass or fail this Verisk SQL question, reported in October 2026. It's a join, a GROUP BY, and a HAVING clause on an average. Nothing exotic. The risk is rushing and writing the filter in the wrong place. If you freeze on the syntax during the live OA, StealthCoder is the invisible safety net that reads the prompt and hands you a clean query. Most candidates won't need it here, but it's good to know it's there.
The problem
The companies table stores canonical company names, and salaries stores employee salaries linked by company identifier. Return the name of every company whose average salary is strictly greater than 40000. Order rows by company_id ascending. TableColumns companiescompany_id, company_name salariesemployee_id, company_id, salary Tables companies: company_id PK (Integer), company_name (Text) salaries: employee_id PK (Integer), company_id (Integer), salary (Integer) Constraints Each table contains between 1 and 100000 rows. Identifiers and names are non-null; every salary row references a company. 0 <= salary <= 1000000000.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is join, aggregate, filter on the aggregate. Join companies to salaries on company_id, GROUP BY company_id and company_name, then use HAVING AVG(salary) > 40000. Putting that condition in WHERE fails, because WHERE runs before grouping and can't see the average. Group by company_id as well as the name so two companies with the same name don't merge. Order by company_id ascending, as the prompt asks. Salary is an integer, but AVG returns a decimal in most engines, so a company averaging exactly 40000 is excluded and one at 40000.5 is included. Don't cast to integer, since that truncates and can wrongly drop a company. Every salary row references a company, so an inner join is safe. If you blank on HAVING versus WHERE during the live OA, StealthCoder can surface the query while you check the strict inequality.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Companies Above a Salary Threshold cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Verisk's OA.
Verisk reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Companies Above a Salary Threshold FAQ
How hard is the Verisk companies salary threshold question really?+
Easy. It's a standard join plus GROUP BY plus HAVING. If you've written an aggregate query with a filter on the aggregate, you can finish this in a few minutes. The only traps are the strict inequality and the ordering clause.
What's the trick in this SQL problem?+
Use HAVING, not WHERE, for the average condition. WHERE filters rows before grouping, so it can't see AVG(salary). Group by company, compute the average, then keep groups where it's strictly greater than 40000.
Should I use an inner join or a left join?+
Inner join works. The problem says every salary row references a company, and a company with no salaries has no average to compare anyway. A left join would only add NULL averages that HAVING drops, so it changes nothing.
Do I need to group by company_id or company_name?+
Group by company_id, and include company_name so it can be selected. Grouping by name alone risks merging distinct companies that share a name. Then order by company_id ascending to match the required output.
How do I prepare for this in 48 hours?+
Write three or four join plus GROUP BY plus HAVING queries from scratch. Practice average, count, and sum filters. Check boundary cases like exactly 40000. Also review ORDER BY on a non-selected column. That covers this question and its close relatives.