Skip to content
Advertisement

mySQL Select All where date is less than 1 day from max date in data

I am having a table name “raw”. The date column is not having all the dates of month as it does not record holidays or when there were no sales for the day. I am trying to get the data form the date less than a day of specific date or max date but it is not returning the search as before the max date was holiday. here are the dates: 2021-07-09 2021-07-07 2021-07-03 2021-07-02 2021-07-01 2021-06-30

Advertisement

Answer

If you want the data from the day before a specific date, then use:

The ? is the specific date.

For the date previous to the maximum date, you could use:

Ouch. Two levels of subqueries. That seems cumbersome. A simpler method is:

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