Skip to content
Advertisement

how to comparison LAG function in mysql

I got complicated problem in mysql.

I have some table on mydatabase.

sample docs(this is only simple sample, actual data are so many table that I have to join)

table “merchant”

table “transaction”

I want to know the information of merchants transaction daily “before” and “after” to comparison

like this below

I tried with this query

but that query didn’t work

Advertisement

Answer

You can use sum() instead of count().

And you also need to enclose identifiers, here the column aliases, in backticks if you use special characters like - in them. Or avoid using special characters in them all together.

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