Hi there,
Is it possible to address a freshly defined SQLite view field by its name in the same query?
Like in this one which is getting ridiculously unreadable:
rs = app.db.sqlselect ("CREATE View "+app.extendedCustomers+" as select *, "+ _
"case when status not like ""cancelled"" then (item_total) else 0 end as RealTotal, "+ _
"case when status not like ""cancelled"" then sum (case when status not like ""cancelled"" then (item_total) else 0 end) else 0 end as Umsatz, "+ _
"case when status not like ""cancelled"" then (item_discount) else 0 end as RealDiscount, "+ _
"case when status not like ""cancelled"" then sum (case when status not like ""cancelled"" then (item_discount) else 0 end) else 0 end as Gesamtrabatt, "+ _
"(sum (case when status not like ""cancelled"" then (item_total) else 0 end) - case when sum (case when status not like ""cancelled"" then (item_discount) else 0 end) Not Null then sum (case when status not like ""cancelled"" then (item_discount) else 0 end) else 0 end ) As Rabattumsatz, "+ _
"count(*) As Bestellungen from customers as c join orders as O , items as i, order_items_link as oil, Parzelle_orderitem_link AS p on c.customer_ID = O.customer_id and i.ID = oil.item_nameID and oil.order_id = o.order_id and p.order_item_ID = oil.ID group by c.customer_id")
success = not app.db.error
I thought I could make the 3rd line rather look like
"case when status not like ""cancelled"" then sum (RealTotal) else 0 end as Umsatz, "+ _
but if I try, SQLite tells me it doesn’t know any field RealTotal. The query above works, but I am afraid what will happen if I have to modify it at some point in the future