(add): Counts backend logic, placeholders
This commit is contained in:
@@ -33,6 +33,13 @@ def init_db():
|
||||
SELECT b.*, t.last_name, t.first_name, t.phone_number, t.pref
|
||||
FROM baskets b LEFT JOIN tickets t ON b.prefix = t.prefix AND b.winning_ticket = t.t_id
|
||||
ORDER BY b.prefix, b.b_id""")
|
||||
cur.execute("""CREATE VIEW IF NOT EXISTS report_counts AS
|
||||
SELECT prefix, COUNT(DISTINCT(CONCAT(first_name, last_name, phone_number))) AS unique_buyers, COUNT(*) AS total_buys
|
||||
FROM tickets
|
||||
GROUP BY prefix
|
||||
UNION ALL
|
||||
SELECT 'Totals', COUNT(DISTINCT(CONCAT(first_name, last_name, phone_number))), COUNT(*)
|
||||
FROM tickets""")
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user