Added counts view to schema
This commit is contained in:
@@ -38,4 +38,12 @@ CREATE VIEW IF NOT EXISTS report AS
|
||||
SELECT b.prefix, CONCAT(t.last_name, ", ", t.first_name) AS winner_name, t.phone_number, t.preference, b.b_id, b.winning_ticket, b.description
|
||||
FROM baskets b LEFT JOIN tickets t
|
||||
ON b.prefix = t.prefix AND b.winning_ticket = t.t_id
|
||||
ORDER BY b.prefix, winner_name, t.phone_number, t.preference, b.b_id;
|
||||
ORDER BY b.prefix, winner_name, t.phone_number, t.preference, b.b_id;
|
||||
|
||||
CREATE VIEW IF NOT EXISTS counts AS
|
||||
SELECT prefix, COUNT(*) AS total_sold, COUNT(DISTINCT CONCAT(first_name,last_name,phone_number)) AS unique_sold
|
||||
FROM tickets
|
||||
GROUP BY prefix
|
||||
UNION ALL
|
||||
SELECT 'Total' AS prefix, COUNT(*) AS total_sold, COUNT(DISTINCT CONCAT(first_name,last_name,phone_number)) AS unique_sold
|
||||
FROM tickets;
|
||||
Reference in New Issue
Block a user