I have written a mysql query that is getting data from two different tables
stock_list
andselected_items
using union.Fromstock_list
I am getting SUM(qty),SUM(weight).Fromselected_items
I am getting COUNT( barcode ) and SUM( weight ) both based on a specific date.And the last query in the union returns the total SUM(qty),SUM(weight) fromstock_list
. This is the query I am using.
SELECT SUM( qty ) AS StockSum, SUM( weight ) AS Stockweight
FROM `stock_list`
WHERE DATE LIKE '08-Jan-2016'
UNION SELECT COUNT( barcode ) AS BilledItems, SUM( weight ) AS Billedweight
FROM `selected_items`
WHERE DATE LIKE '08-Jan-2016'
UNION SELECT SUM( qty ) AS TotalStock, SUM( weight ) AS TotalWeight
FROM `stock_list`;
The problem is everything gets displayed in two columns StockSum and Stockweight.I would like to have 6 separate columns plus I would like to add an extra column for date at the beginning.
This is my current output.