Skip to content
Advertisement

Select from a result of another select

I am trying to select results from the result of another select but I am getting an error. Below is the sql query.

Advertisement

Answer

In case you are using MariaDB 10.2, which is the first version to accept window functions, have a look at the SQL Fiddle I just prepared with random data. Take into account that for DDL purposes, I changed the date column name to date_.

You either create a CTE to control the data, which to me is easier to read than a nested SELECT statement:

Or give a name to the nested query you just made at the end of it after closing parentheses:

Same result for both cases 🙂

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