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 3 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:
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
Sum of Column in a Database Table
Sum of Column in a Database Table   ... to calculate the sum of specific column in database table. Here is the code of program... of specific column data in the database table. Consider an example of any
Advertisements
sum of all values in a column of jtable
sum of all values in a column of jtable  hey everyone, is there a code to display the sum of all values in a column of a jtable namely CARTtbl in a jabel without using a button,and the sum will change when an item is added
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
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
How to Delete a column and Add a new column to database
How to Delete a column and Add a new column to database   How to Delete a column and Add a new column to database   Hi, The following query is executed for add and delete a column in a table- for drop a column
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
Make Unique Column in Database Table
Make Unique Column in Database Table   ... a unique key in a column of a database table. While declaring unique key in a column we should check whether this column is eligible to store a unique
Delete a Column from a Database Table
Delete a Column from a Database Table   ... to delete a column from a database table. We are not going to create a new table... a column from a database table then we have been provided with the  database
MySQL Column Type Database
MySQL Column Type Database     ... of column in MySQL . MySQL supports the numeric type , Date and time type, and String type (char) database. MySQL Numeric type and String type Database
Remove Unique Column in Database Table
Remove Unique Column in Database Table   ... unique field of the particular column in a database table.  We know... the particular column in the database table. In this query we will give table and column
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
Adding a New Column Name in Database Table
Adding a New Column Name in Database Table  ... are going to learn about adding a new column in database table. Sometimes it happens...; Above code is used for adding a new column in the database table and takes
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
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
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  Hello Sir, I have developed a swing application in which database table... ,update,delete database values from jtable only so i added three buttons add
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  Hello Sir, I have developed a swing application in which database table is shown... ,update,delete database values from jtable only so i added three buttons add,update
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  Hello Sir, I have developed a swing application in which database table is shown... ,update,delete database values from jtable only so i added three buttons add,update
Arrange a Column of Database Table
Arrange a Column of Database Table   ... : This query shows data of a column in ascending order of the specific database table... for arranging the data of database table in ascending order. Firstly we should know
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
Arrange a Column of Database Table
Arrange a Column of Database Table   ... that arrange the records of database table in descending order. The descending... with MySQL database. As soon as the connection gets established it takes a table
sum
sum
sum
sum
sum
sum
sum
sum
How to insert multiple drop down list data in single column in sql database using servlet
How to insert multiple drop down list data in single column in sql database using servlet  i want to insert date of birth of user by using separate drop down list box for year,month and day into dateofbirth column in sql server
Hibernate criteria sum.
Hibernate criteria  sum. Here, we will introduce you to about the sum() function . It returns the sum of total value of column. Syntax : Criteria... message as shown below: Hibernate: select sum(this_.fee
displaying data for a single column from Mysql database in the list box in php form
displaying data for a single column from Mysql database in the list box in php form  I have a form in php.want to display data from a single column...('include/functions.php'); $Select = "SELECT * FROM category_master"; $Q = mysql
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 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 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
Change Column Name of a Table
for renaming a column name in a database table. As we know that each table keeps... Change column name in a database table example! Enter table name... Change Column Name of a Table   
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
Calculate sum and Average in java
Calculate sum and Average in java  How to calculate sum and average...(); int num = Integer.parseInt(data); int sum = 0; float avg = 0.0f; for (int i = 1; i <= num; i++) { sum = sum + i
Blob column
Blob column  Hi all... How to store an excel file in Blob column? I m using oracle 11 g database
display multiple image file or pdf file in multiple column of a row from server or database
display multiple image file or pdf file in multiple column of a row from server or database  hello sir I have uploaded the file to the server and I want to display that file to the user page but I want to display that file
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. Thanks
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
Delete a column
Delete a column       In this section, you will learn how to delete a column from database table using jpa. You need the following artifacts: Database table: student Model
SQL Aggregate Sum
-set by column name'stu_id'. select stu_id, stu_name, sum(marks... SQL Aggregate Sum       The SQL Aggregate Sum Function is a part of Aggregate Function that is used
MySQL Addition
; MySQL Addition returns you the sum value of a specific column for a group.... Syntax: SUM([DISTINCT] column_name): Returns the sum of the values of the column column_name. If there are no rows then SUM() returns NULL
column matrix
column matrix  columan wise total matrix
column matrix
column matrix  columan wise total matrix
Advertisements
 

 

 

DMCA.com