sum database column

sum database column

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

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   ... be used to calculate the sum of specific column in database table.ADS_TO_REPLACE_2... 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-ADS_TO_REPLACE_1 for drop
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
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
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 :ADS
Remove Unique Column in Database Table
Remove Unique Column in Database Table   ... unique field of the particular column in a database table.  We know... from the particular column in the database table. In this query we will give table
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...; data_type; Above code is used for adding a new column in the database table
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
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   ... for arranging the data of database table in ascending order. Firstly we should know...,......... Here we are going to give an example to arrange the data of a column
Arrange a Column of Database Table
Arrange a Column of Database Table   ... Arrange a Column of Database Table... that arrange the records of database table in descending order. The descending
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
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
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
Change Column Name of a Table
for renaming a column name in a database table. As we know that each table keeps...\jdbc\jdbc-mysql>java ChangeColumnName Change column name in a database... Change Column Name of a Table   
Blob column
Blob column  Hi all... How to store an excel file in Blob column? I m using oracle 11 g database
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
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
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
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...: select sum(this_.fee) as y0_ from studentinfo this_ Total of fee columm
MySQL Addition
; MySQL Addition returns you the sum value of a specific column for a group.... Syntax:ADS_TO_REPLACE_1 SUM([DISTINCT] column_name): Returns the sum of the values of the column column_name. If there are no rows
sum
sum
sum
sum
sum
sum
sum
sum
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
Change Column Name in MySQL
.style1 { color: #0000FF; } Change Column Name in MySQL In this example How to change column name in MySQL. First of all we have created MySQL database with many fields in table. We rename a column in MySQL using alter
Getting Column Names from a database table in Java
Getting Column Names from a database table in Java  ... with code that retrieves all columns name in a specific database table. Sometimes... database through the JDBC driver. After establishing the connection then you get
column matrix
column matrix  columan wise total matrix
column matrix
column matrix  columan wise total matrix
DATABASE QUERY
want sum of column Please help me out!!!!!!!!!!!!!!111   Hi...DATABASE QUERY  Sir, I'am making a project where the database has...:___ here I have 2 display the sum of earning and expenditures of all
database
database  In my project where u helped me to display the databases present im mysql database on the Jlist and then the respective tables in that database on another jlist and then the column names on another jlist I dont want
database
database  In my project,i want the user to specify the name of the database he wants to create in mysql and then also the name of the table along with the column names he wants in that database....Im doing my project in netbeans
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
database
the names of the databases present in mysql database on a Jlist that is already present on the gui and when the user selects a particular database,the tables present under that database should be displayed on another Jlist which is present

Ads