Skip to content

Tag: sql

How to Further Group Items in a Column After Group By

I have an SQL table named “DATA” as follows: I’m attempting to return the following 3 columns: plan, planCount, totalCostPerPlan I’ve been working a query to return this and so far it looks like this: It sort of works, however, I get the data only partially grouped as follows: (The tab…

SQL query returns 0 for COUNT(*) if no rows

I just got started with SQL and joined this forum recently, thus I’m still lacking the knowledge. Please do be considerate if I’ve made any mistakes. I intend to get the data from the past n days. For each day, the query will count the total rows and return the result. However, there are no record…

Top 3 services used for each day – SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question The query below gives me top 3 services for 6th June 2021. I want to repeat this for each day …

How to combine multiple records in one in SQL

I have a SQL table that looks something like this: OP ID First name Last name Phone number I 123 John Smith 888-555 U 123 777-555 I have to combine this rows through select query into something like this: ID First name Last name Phone number 123 John Smith 777-555 I have trouble writing query because my only …