Skip to content
Advertisement

sqlite query based on selecting from column string and filtering by last rows in descending order

I have a database, tick_df, that looks like this

I am trying to select all columns and the last 2 rows in descending time order from only one symbol – e.g.AVAX/USD:USD. The query I have tried is

But this return an error

can anyone point to what I’m doing wrong here.

Thanks

Advertisement

Answer

If you look at the error message it tells you that there is a syntax error near ORDER BY, it hints to an error immediately before that clause.

As you can read from the documentation:

A string constant is formed by enclosing the string in single quotes (‘).

You should enclose the LIKE arg in single quotes like this

Also, if you want to return all the column you should SELECT * and not SELECT symbol because the latter will only return the symbol column.

The final correct query should be

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