Quite apart from your misspelling of
there are several other aspects you will need to change. Exactly how and what depends on which version of SqlLite you are using and you have not shared that information.
A good starting point is always the documentation - e.g. If you have 3.5 or better, to change your Window functions ROW_NUMBER and SUM you will need to conform to the syntax at Window Functions
Equally, if you look up the documentation for SELECT
] you will see that the
will be at the end of the query so instead of
SELECT TOP 1000000
ORDER BY cust_id, date, seq;
You will have
ORDER BY cust_id, date, seq
I will say here though, 1,000,000> is a big
limit! Most of us usually use just 1,000 (or smaller) whether it be for debugging purposes or limiting extracts intended for UI components.
I also think (I may be wrong) that you will need to change the bit
FROM trans_payments) t (ID, cust_id, final, value, balance, date, note, seq)
I'm pretty sure you have to use
) AS t
and I don't think SqlLite supports the list of column names like that. If not then you can name the columns in your sub-query e.g.
SELECT ID, cust_id, final, 0 AS [Value], [final balance], [date], note, 0 AS seq
Note that I have put square brackets around
- you cannot have spaces in column names unless you delimit them. SQL Server and SQLLite use
, other languages may have other delimiters.
I've done the same with
because those are reserved words
That is hopefully enough to get you going