# Why Count (1), when we use Count(*)

#1

Hi there,

Need to know why the Count(1) was used in the query below: as i have understood when we use count(*) it counts total rows in the table. What Count(1) is suppose to count?

select date(ordered_at), count(1)
from orders
group by 1
order by 1;

Thanks,
MAK.

#2

Please post the URL to this exercise. It looks like it might have something to do with aggregate functions, but we still need to see the exact exercise to answer your question.

#3

## Hi, Thanks for your reply… actually i am learning SQL on codecademy… and below is the lesson and its instruction

Daily Count 2

Great! Now that we can convert timestamps to dates, we can count the Orders Per Date. Generally, when we count all records in a table we run a query with the count function, as follows:
select count(1) from users;

This will treat all rows as a single group, and return one row in the result set - the total count.
To count orders by their dates, we’ll use the date and count functions and pair them with the group by clause. Together this will count the records in the table, grouped by date.

For example, to see the user records counted by the date created, we use the date and count functions and group by clause as follows:

## select date(created_at), count(1) from users group by date(created_at)

INSTRUCTION:

Use the date and count functions and group by clause to count and group the orders by the dates they were ordered_at.

select /**/
from orders
group by 1
order by 1;
We now have the daily order count!

## The order by 1 and group by 1 statements are shortcuts for order by date(ordered_at) and group by date(ordered_at).

Thats the reason i got confuse, why we are using ‘count(1)’ and what exactly it calculates?

Thanks once again.
MAK.

#4

We are still powerless without that URL to the lesson.

#5