0

Much like in this answer, how can I achieve the same thing in SQL?

I want to group the data first by site, then by date and then have a count that shows number of bookings on that date.

The result would be something like this:

Site1   2021-03-04      9
Site1   2021-03-05      5
Site1   2021-03-06      4
Site2   1900-01-01      1
Site2   2020-12-30      1
Site2   2021-01-04    325
Site2   2021-01-05    520
Mus
  • 7,290
  • 24
  • 86
  • 130
  • 1
    Seems, you need SELECT T.SITE,T.DATE,COUNT(*)CNTT FROM YOUR_TABLE AS T GROUP BY T.SITE,T.DATE – Sergey Feb 12 '21 at 15:50
  • @Sergey This is it. Delete your comment then post it as an answer so that I can accept. – Mus Feb 12 '21 at 15:56
  • This is the beautiful thing about SQL; you say you want to group your data by site and date and this translates to `GROUP BY site, date`. You say you want to have a count and this becomes `SELECT COUNT(*)`. SQL statements for simple queries are often close to how we describe the task in English language. – Thorsten Kettner Feb 12 '21 at 16:08

1 Answers1

0
SELECT T.SITE,T.DATE,COUNT(*)CNTT FROM YOUR_TABLE AS T GROUP BY T.SITE,T.DATE 

Based on your description you need something like this query

Sergey
  • 4,719
  • 1
  • 6
  • 11