Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners sum database column

Have Programming Question? Ask it here!
 
 
 


Godwin
sum database column
1 Answer(s)      a year and 7 months ago
Posted in : Java Beginners


please i have two columns-col1 and col2, col1 contain item and col2 contain the quantity of the item

col1 col2 Key 4 Soap 5 seat 4 Key 3 Soap 4

how will i query the database to sum the Items and display output so that it will be like this col1 col2 Key 7 Soap 9 Seat 4

thanks


Advertisement
View Answers

January 7, 2013 at 12:59 PM


hi friend, use MySQL(group by) keyword to solve your problem. Here I am giving a sample SQL query hope this will helpful for you.

select item, sum(quqantity) from `order` group by item


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com