Mulai sekarangMulai gratis

Find the outliers

The previous exercise showed us that Saturday was the busiest day of the month for BikeShare rides. Do you wonder if there were any individual Saturday outliers that contributed to this?

Latihan ini merupakan bagian dari kursus

Writing Functions and Stored Procedures in SQL Server

Lihat Kursus

Instruksi latihan

  • Use SUM() and DATEDIFF() to find the Total Ride Hours per day starting from seconds.
  • Use CONVERT() to SELECT the date portion of StartDate.
  • Use DATENAME() and CONVERT() to select the WEEKDAY.
  • Use WHERE to only include Saturdays.

Latihan interaktif langsung praktik

Cobalah latihan ini dengan melengkapi kode contoh ini.

SELECT
	-- Calculate TotalRideHours using SUM() and DATEDIFF()
  	___(___(___, StartDate, EndDate))/ 3600 AS TotalRideHours,
    -- Select the DATE portion of StartDate
  	___(___, StartDate) AS DateOnly,
    -- Select the WEEKDAY
  	___(___, ___(___, StartDate)) AS DayOfWeek 
FROM CapitalBikeShare
-- Only include Saturday
WHERE ___(___, StartDate) = 'Saturday' 
GROUP BY CONVERT(DATE, StartDate);
Edit dan Jalankan Kode