brad62 — 2012-05-15T04:27:03-04:00 — #1
I have a table with ticket sales.
In one column the amount of tickets the customer order is listed.
So, if one order 2 tickets that column will show 2, if someone order 8 tickets, that column is showing 8, a.s.o.
Now I would like to just pick out the sum of all tickets sold so far.
Don't know how to do that. What should I use? I guess there is something very simple to do this.
The table is called showtickets
The column is called tickets
guido2004 — 2012-05-15T04:32:20-04:00 — #2
prtag — 2012-05-16T04:23:11-04:00 — #3
select sum(tickets) as num from showtickets;
or you can use group by to sum by date or user, fo \r example for all tickets sold today:
select sum(tickets) as num from showticket where today_field_name = CURDATE() group by today_field_name;
r937 — 2012-05-16T07:36:17-04:00 — #4
an unfortunate example, because there's only going to be one value in the GROUP BY column, hence it's not required
a better example would show the sum for each day in the last 7 days
brad62 — 2012-05-21T08:35:01-04:00 — #5
I really didn't get all this. How should I write that line to make it work?
r937 — 2012-05-21T08:40:39-04:00 — #6
SELECT SUM(tickets) AS total