Sum database colum in java

Sum database colum in java

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

columns and their corresponding quantity: cup 4, Soap 5, seat 4, cup 3, Soap 4

how will i query the database to sum the Items and display output so that it will be like this Cup 7, Soap 9, Seat 4.

thanks

View Answers

January 7, 2013 at 12:19 PM

hi friend, You can use the (group by) SQL keyword to solve your problem. Here I am giving the SQL query against your question what you have asked.

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

Here item, and quantity are columns and order is a table.









Related Tutorials/Questions & Answers:
Sum database colum in java
Sum database colum in java  please i have two columns-col1 and col2... the database to sum the Items and display output so that it will be like... question what you have asked. select item, sum(quqantity) from `order` group
sum database column
sum database column  please i have two columns-col1 and col2, col1... 3 Soap 4 how will i query the database to sum the Items... for you. select item, sum(quqantity) from `order` group by item
Advertisements
Sum of Column in a Database Table
Sum of Column in a Database Table   ... be used to calculate the sum of specific column in database table.ADS_TO_REPLACE_2...-mysql>java SumColumn Sum of the specific column! Enter table name
Calculate sum and Average in java
Calculate sum and Average in java  How to calculate sum and average in java program?   Example:- import java.io.BufferedReader; import...(); int num = Integer.parseInt(data); int sum = 0; float avg
sum
sum  a program to find the sum of the alternative diagit of it ex- no=123456 sum=1+3+5=9
sum
; sum=sum+s; if(i==n){ System.out.print(s...+"+"); } System.out.print("\nSum of the series : "+sum
Java Sum of Digits
Java Sum of Digits In this Java Tutorial section, you will learn how to find the sum of multidigit number. For this purpose, we have allowed the user to enter... for Sum of Digits in Java: import java.util.*; class SumOfDigits { public
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26 (adsbygoogle
Sum - JSP-Servlet
the total sum of items from database using Java servlet or Jsp and html form. It should display the affected rows and the total sum of all in a seperate column..., Sum Into Database Salary
1-2+5-10+17-26 sum the series - Java Beginners
1-2+5-10+17-26 sum the series  1-2+5-10+17-26 sum the series  Hey Ankit, Try the following code. public class SumOfSeries3 { /** * @param 'series' holds the series need to be printed */ StringBuffer
Sum of integers
Sum of integers  A Java program that reads an integer value from the user and displays i) the sum of all even integers between 1 and the input value, both inclusive. ii) The sum of all odd integers between 1 and the input
Find sum of all the elements of matrix using Java
Find sum of all the elements of matrix using Java A matrix is a rectangular... dimensional array. Now to determine the sum of all these elements, we have initialized a variable sum to 0 and create for loops to iterate throughout the array
Sum of two numbers using command line arguments in Java
? The calculate the sum of two numbers using command line arguments in Java... sum = a+b; Check complete example code at Add Two Numbers in Java. Thanks...Sum of two numbers using command line arguments in Java  Hi, How
sum in JTable
sum in JTable  how to calculate sum from JTable's one field like total
sum of the series
sum of the series  Program to sum the series 1+1/1!+1/2!+1/3!+....n
JPA Sum Function
JPA Sum Function       In this section, you will learn about sum function of aggregate function of JPQL (Java Persistence Query Language). The sum function to calculate the sum
Sum of seris
Sum of seris  Program to find the sum of the following series using a function declaration. sum=x-(xxx)/3!+(xxxxx)/5!-(xxxxxxx)/7!+.....(xx....x)/n!. Where n and x are entered from the keyboard
Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum... numbers from the file and then calculate their sum. Here is the code
Sum of first n numbers
Sum of first n numbers  i want a simple java program which will show the sum of first n numbers....   import java.util.*; public class...=input.nextInt(); long sum=0; for(int i=1;i<=n;i++){ sum+=i
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
sum
sum
sum
sum
sum
sum
sum
sum
java database
java database  help me with this...i never learn build java database... to design and implement objects needed for a program that maintains a database.../teacher information, search it, alter it, etc. The database is maintained as a list
A program to find the sum of odd number
A program to find the sum of odd number In this section you will learn how to find the sum of odd number in the series up to the given number in java... the console. Now here is the simple example which will help you to find the sum of odd
sum of fibonacci series
sum of fibonacci series  Write a Java program to print Fibonacci series upto n and find their sum also. 0+1+1+2+3+5+8+13+21ΓΆβ?¬Β¦ΓΆβ?¬Β¦ΓΆβ?¬Β¦ΓΆβ?¬Β¦=sum   Hi, Please see the thread Fibonacci program
JAVA DATABASE CONNECTION WITH JTABLE
JAVA DATABASE CONNECTION WITH JTABLE  HOw To Load Database Contents From Access Database to JTable without using Vector
Database,Java
Database,Java  help me for the following things if one customer... me the how to write the query in MySQL database and i want coding for this one in Java.because i am using Java as the front end.   1)page.jsp: <
java and database
java and database  sir i want to prepare a sign in form and i want to check that user name is exist or not in database if it is exist in database then return it is allready exist otherwise it is registered in data base thank u
Map java Object to database.
Map java Object to database.  How do you map Java Objects with Database tables
Database programming - Java Beginners
Database programming  How to do a Database programing with Balanced Multiway Tree(B+ Tree,not Binary Tree) in java
ModuleNotFoundError: No module named 'sum'
ModuleNotFoundError: No module named 'sum'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'sum' How to remove the ModuleNotFoundError: No module named 'sum' error
ModuleNotFoundError: No module named 'sum'
ModuleNotFoundError: No module named 'sum'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'sum' How to remove the ModuleNotFoundError: No module named 'sum' error
sum and average of grades
sum and average of grades  how to print a program which is sum and average of Korean (90), English(85), Mathematics(78), Biology(65), Chemistry(83
Sum - JSP-Servlet
Sum  Hi Guys, thank you all for support for us all. Please I want to sum up from a particular row from the database, get all the rows affected... = con.createStatement(); ResultSet res = st.executeQuery("SELECT SUM(amount) FROM
Display Sum of Table Column Using In JSP
Display Sum of Table Column Using In JSP... an application to Display the sum data of a Table column for a specific Date. We created five file sum_count.jsp, resultForm.jsp, result_count.jsp, sumcount.java
Java Database Program
Java Database Program   Write a program in Java that connects to a database and generates a report consisting of the courses in whom the total percentage of number of students failed is more than 80% of the total number
calculate sum of individual digit
calculate sum of individual digit   How calculate product of first and last digit of indiviual numbers Like a=43278 4*8=32
Sum of positive and negative numbers
Sum of positive and negative numbers  Hi if someone could help... the sum of all the positive integers and the sum of all the negative integers.  ...]; } } System.out.println("Sum of positive numbers: "+sum2); System.out.println
Using sum() in hibernate criteria.
Using sum() in hibernate criteria.  How to calculate sum() in hibernate criteria by using projection?   You can calculate sum of any...(employee); } } } Output: Hibernate: select sum
Calculate the Sum of three Numbers
Calculate the Sum of Three Numbers       This is simple java programming tutorial . In this section you will learn how to calculate the sum of three numbers by using three
database
links: Connect JSP with database Mysql Connect Java with database Mysql...database  tell me use about database and give me a small program.   It is secure and can easily be accessed, managed, and updated. Moreover
database
links: Connect JSP with database Mysql Connect Java with database Mysql...database  tell me use about database and give me a small program.   It is secure and can easily be accessed, managed, and updated. Moreover
database
links: Connect JSP with database Mysql Connect Java with database Mysql...database  tell me use about database and give me a small program.   It is secure and can easily be accessed, managed, and updated. Moreover
How do you sum a dictionary
How do you sum a dictionary  Hi, I want to sum the values of two dictionary based on keys. How do you sum a dictionary

Ads