Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

sql query help

Posted on 2009-05-03
2
233 Views
Last Modified: 2012-05-06

hello there,

i have a table which contains product names and qty.they are repeated many times inthe table.i want to collect all the product and sum their qty.
for e.g.

p1   200
p2  300
p3   200
p1  100
p1  200
p2  50

now i want three rows like this
p1 XXX
p2 XXX
p3 XXX

where XXX is the sum of all its qty
0
Comment
Question by:zolf
2 Comments
 
LVL 7

Accepted Solution

by:
Chandan_Gowda earned 250 total points
ID: 24292951
try the attachment
query.txt
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 24292952
a simple group by should do
select product_id, sum(amount) from yourtable group by product_id

Open in new window

0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question