Count times a record appears in Mysql [closed]

1

I have this mysql table

As you can see in the day column I have two days "po" and "20", what I need is a query that returns me the number of days that are registered, which in this case is 2.

I have this:

SELECT COUNT(*) AS total FROM juego WHERE fecha = '2018-12-23' GROUP BY jornada
    
asked by Jorge Alonso 20.12.2018 в 01:01
source

2 answers

0

I found the solution, remove the grouping and add the distinct modifier to count the different elements

SELECT COUNT(DISTINCT jornada) AS total FROM juego WHERE fecha = '2018-12-23'
    
answered by 20.12.2018 / 01:32
source
0

It seems to me that your query is well initiated, the only thing is that in the aggregation function COUNT() instead of the wildcard * you pass directly the name of the column you want to count

SELECT COUNT(jornada) AS Total
FROM juego 
GROUP BY fecha;

Now for the sample of data that you place, I see the use of WHERE fecha = ... unnecessary since all your data have the same date

    
answered by 20.12.2018 в 01:14