Question

Trending Data Back for Previous Days

  • 22 April 2021
  • 0 replies
  • 26 views

Hi all,

 

Hoping someone can help me - I have a simple SQL query that pulls a count of customers for the current date, although I want to trend that back for, let’s say arbitrarily, 2 years. How would I go about this?

 

SELECT 

CAST(CURRENT_DATE() AS TIMESTAMP) AS Date, 

COUNT(DISTINCT CustomerId) AS CustomerCount 

FROM table

WHERE CURRENT_DATE() >= DATE(CustomerAdded)

 

Thanks!


0 replies

Be the first to reply!

Reply