HomeInterview QuestionsExplain the following SQL query: SELECT customer_n…

Explain the following SQL query: SELECT customer_name, COUNT(*) FROM customerTable WHERE CITY_Name LIKE '%Pu%'

🟢 Easy Conceptual Junior level
1Times asked
May 2026Last seen
May 2026First seen

💡 Model Answer

The query attempts to retrieve each customer’s name along with the number of rows that match the condition where the city name contains the substring 'Pu'. It uses the COUNT(*) aggregate function to count rows. However, because the SELECT clause includes customer_name without a GROUP BY clause, most SQL engines will raise an error unless customer_name is functionally dependent on the primary key or the query is run in a mode that allows non-aggregated columns. In a standard ANSI‑SQL context, you would need to add GROUP BY customer_name to group the counts per customer. The LIKE '%Pu%' predicate performs a case‑sensitive pattern match, returning rows where the CITY_Name column contains the letters 'Pu' anywhere in the string. If the database is case‑insensitive, it will match 'Pu', 'pu', 'PUL', etc. The result set would have two columns: customer_name and the count of matching rows for that customer.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500