2. Daily Counts - SQL Analysing Business Metrics

Hola que tal, or fa quien me ayuda con este tema de como hacer la sintaxis correcta.

Let’s get a Daily Count of orders from the orders table. Complete the query using the date function to cast the timestamps in ordered_at to dates.

select /**/
from orders
order by 1
limit 100;

The order by 1 statement is a shortcut for order by date(ordered_at). The 1 refers to the first column.

select date(ordered_at)
from orders
order by 1
limit 100;

1 Like

SELECT DATE(ordered_at),COUNT(1) FROM orders
GROUP BY DATE(ordered_at);

The interface is buggy on this question, the ambiguity of the actual question also doesn’t help.

***One MUST use the RUN button. CTRL+ENTER runs the script but doesn’t always trigger the check for some reason.

**What the questions is asking is to output a truncated version of all the order dates (one column). **

Answer below but I’d encourage you to try once again

select date(ordered_at)

from orders

order by 1

limit 100;

Really? That’s what “Daily Count of orders” means?
A truncated version of all the order dates?

How does this even make any sense?

This is a very poor quality lesson, I am abandoning it.

2 Likes