title: Total orders by new customers Each day and week
body: <p>I'm fairly new to SQL and I'm trying get total orders by new customers every day and each week in Mysql ( feel free to answer in any sql versions). First I tried to get total orders by new customers every day by writing below query, however Im getting incorrect results.</p>
  <pre><code>select COUNT(u.orderId), date(u.createdAt) as ord_dt, u.userId
  from userorder u 
      inner join
          (
              select userId, min(date(createdAt)) as first_date
              from userorder 
              group by 1
          ) g 
          on g.userId =  u.userId
  where g.first_date &lt; date(u.createdAt)
  group by 3
  </code></pre>
  <p>Link to the dataset <code>https://docs.google.com/spreadsheets/d/1fA6hAkDJgp28BF0G0aSe9Ml64S9cIwch/edit?usp=sharing&amp;ouid=104686423957654811582&amp;rtpof=true&amp;sd=true</code></p>
  <p>Any help is appreciated</p>