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

Ads









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
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
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
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
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
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
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
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
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   ... 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
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
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 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
Blob column
Blob column  Hi all... How to store an excel file in Blob column? I m using oracle 11 g database
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
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
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
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
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
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
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
sum
sum
sum
sum
sum
sum
sum
sum
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... a static method inside which creates the connection with MySQL database through
Change Column Name in MySQL
database with many fields in table. We rename a column in MySQL using alter...: This is a data type of new column. First of all you will create MySQL database... .style1 { color: #0000FF; } Change Column Name in MySQL
column matrix
column matrix  columan wise total matrix
column matrix
column matrix  columan wise total matrix
database
database  how to get information about database like, what are the names of tables that database includes ? what are the names of fields in corresponding tables ? in mysql database on linux environment   Here is a code
Get Column names using Metadata in jsp
an example that retrieves all column names from a database table student1. Create... Get Column names using Metadata in jsp       This section illustrates you how to get column names
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
database  database
database
database  database application
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

Ads