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
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;
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
I really didn't get all this. How should I write that line to make it work?
SELECT SUM(tickets) AS total
This topic is now archived. It is frozen and cannot be changed in any way.