This is something inside MSSQL. If I create a script sq.sql, with:
go
select
b.id, b.deleted, b.customer, b.invoice_date, b.subtotal, b.taxrate, b.tax, b.total, customer_lookup, firstname_lookup, billing_address_lookup, billing_city_lookup, billing_country_lookup, billing_postal_code_lookup, billing_state_lookup from (select
demo_invoices.id, demo_invoices.deleted, demo_invoices.customer, demo_invoices.invoice_date, demo_invoices.subtotal, demo_invoices.taxrate, demo_invoices.tax, demo_invoices.total, demo_customers_34.lastname as customer_lookup, demo_customers_34.firstname as firstname_lookup, demo_customers_34.address as billing_address_lookup, demo_customers_34.city as billing_city_lookup, demo_customers_34.country as billing_country_lookup, demo_customers_34.postalcode as billing_postal_code_lookup, demo_customers_34.state as billing_state_lookup, row_number() over ( order by demo_invoices.invoice_date desc) as rownum from demo_invoices as demo_invoices left outer join demo_customers as demo_customers_34 on demo_invoices.customer =
demo_customers_34.id where cast(cast(demo_customers_34.lastname as decimal(20, 10)) as varchar(20)) like '%leo%' and demo_invoices.deleted=0) as b where rownum >= 1 and rownum < 4 order by rownum;
go
and run it:
sqlcmd -S localhost -U sa -P 'password' -i sq.sql
Changed database context to 'jam'.
Msg 8114, Level 16, State 5, Server dbabic-VirtualBox, Line 1