Skip to content

Instantly share code, notes, and snippets.

@ardianta
Created November 11, 2024 02:46
Show Gist options
  • Select an option

  • Save ardianta/f55732fb75b4254ac1fbfef4ca751e1e to your computer and use it in GitHub Desktop.

Select an option

Save ardianta/f55732fb75b4254ac1fbfef4ca751e1e to your computer and use it in GitHub Desktop.

Revisions

  1. ardianta created this gist Nov 11, 2024.
    11 changes: 11 additions & 0 deletions select_most_booking_hours.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    SELECT
    HOUR(CONVERT_TZ(`bookingCreatedAt`, '+00:00', '+08:00')) AS jam, -- convert UTC time to local time +08:00
    COUNT(*) AS total_booking
    FROM
    Booking -- table name
    WHERE
    YEAR(`bookingCreatedAt`) = 2024 AND MONTH(`bookingCreatedAt`) = 10 -- month of year 2024
    GROUP BY
    jam
    ORDER BY
    jam LIMIT 100