Tuesday, 15 February 2011

mysql - How to place a UNION record into a specific query row -



mysql - How to place a UNION record into a specific query row -

is possible construction in mysql query?

+---------+------------+--------+ | name | date | total | +---------+------------+--------+ | bob | 2014-10-09 | 100.00 | | roy | 2014-10-09 | 200.00 | | joy | 2014-10-09 | 150.00 | | total | 3 | | | jim | 2014-10-10 | 100.00 | | lin | 2014-10-10 | 300.00 | | total | 2 | | | | total | 850.00 | +---------+------------+--------+

right have query looks this:

(select r.id id, concat(g.fname,' ',g.lname) name, r.arrival arrival, r.departure departure, datediff(r.departure, r.arrival) days, u.unit_nickname unit, r.total_price reservations r, guests g, units u g.id=r.guest , r.unit = u.id , r.deleted_at null having r.arrival between '2014-10-01' , '2014-10-30' order r.arrival) union (select "totals", "", count(arrival), "", "", "",sum(total_price) reservations)

obviously columns different gist same. after each day want display count of reservations on day. possible in mysql?

right 1 lastly record of "totals" , total reservations overall along total money (i want maintain record).

mysql sql join union

No comments:

Post a Comment