Skip to content
Advertisement

Unable to filter SQL data from last 30 days

I want to collect data from SQL from the last 30 days. This code shows data of all time

this shows nothing, instead of showing last 30 days data.

All SQL entries were made within the last 30 days. also tried

What am I doing wrong here ? database dtime section

Advertisement

Answer

Try this:

The second doesn’t work because you put GROUP BY before WHERE statement, which is not correct SQL order.

As for why the third code doesn’t work, I’m not sure, but if I had to guess, it has something to do with that DATE_SUB statement.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement