This is my output tabe: 
name    SUM(billing.quantity)   SUM(billing.total)  SUM(billing.discount)   SUM(billing.price)
pen       4                        40                 8                                          32
pencil      3                      15                 2                     13
rubber     1                         2                  1                    1

Using :
SELECT productmaster.name, SUM(billing.quantity), SUM(billing.total), SUM(billing.discount), SUM(billing.price) FROM billing AS billing LEFT JOIN productmaster AS productmaster ON (productmaster.id = billing.pid) GROUP BY billing.pid ORDER BY productmaster.name ASC
 My doubt is , my output should be like 
 name   quantity   total     discount     price
 pen      4         40          8           32
pencil    3          15          2          13
rubber     1         2           1           1
How ? Can any one? I need your help?

SELECT productmaster.name, SUM(billing.quantity) AS Quantity, SUM(billing.total) AS Total, SUM(billing.discount) AS Discount, SUM(billing.price) AS Price FROM billing AS billing LEFT JOIN productmaster AS productmaster ON (productmaster.id = billing.pid) GROUP BY billing.pid ORDER BY productmaster.name ASC

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.