TGViewer
Coding Interview Preparation Coding Interview Preparation @coding_interview_preparation · 5.9K subscribers
Post #1165 708
Coding Interview Preparation SQL question: What will this query return?
Hey everyone, quick follow-up to today’s SQL quiz!👇

The query was:
SELECT COUNT(*) FROM employees HAVING COUNT(*) > 0;

Our active members picked B) 1, C) 0 or D) Error… but let’s break it down real quick! ⚡

➡️ COUNT(*) in the SELECT counts ALL rows in the table → with 10 rows it returns 10

➡️ The HAVING clause filters after aggregation

➡️ HAVING COUNT(*) > 0 simply checks if the total count is greater than 0 (which it always is unless the table is empty)

🟢 So the query returns exactly one row with the value 10.

The question was a valid (just a bit tricky/wordy) way to write
give me the total row count, but only if there’s at least one row



Correct answer: A) 10 ✅

Unfortunately no one got it right😅
Better luck next time folks, you’re all still SQL legends in my book! 💙
  • ❤ 3
More from @coding_interview_preparation
  1. Oct 12, 2026Java Coding Interview Questions Easy 1. Reverse a string without using a built-in reverse…
  2. Oct 10, 2026100 SQL interview questions
  3. Oct 8, 2026If you're prepping for system design interviews, this repo is gold It contains a curated,…
  4. Oct 6, 2026document post
  5. Oct 4, 2026💼 Why Your Resume Gets Rejected Before a Human Reads It You may have good skills and proj…
  6. Oct 2, 2026🧠 Coding Myths You Should Stop Believing There's a lot of advice online about learning to…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →