Heres my SQL code
SELECT system.name, ceil(sum(((comp.price*1.3)/100)))*100-1 Computed_value, 'total_price' as type
FROM Computersystem system, component comp
WHERE system.name='Corporal' AND
((comp.name = gpu) OR
(comp.name = cpu) OR
(comp.name = ram) OR
(comp.name = mainboard) OR
(comp.name = computercase))
GROUP BY system.name
UNION
SELECT system.name, min(currentStock) minCurrent, 'minCurrent' as type
FROM stock st, Computersystem system
WHERE system.name='Corporal' AND
((st.name = gpu) OR
(st.name = cpu) OR
(st.name = ram) OR
(st.name = mainboard) OR
(st.name = computercase))
GROUP BY system.name;
Which outputs
Now instead want to get a table that has one row with:
____Name_____Total Price______minCurrent____
Is there a way i can do this?
If I have got the question correctly, the query be like (on top of the UNION)
SELECT name, SUM(computed_value) TotalPrice, wm_concat( type )
group by name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.