Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

select statement that adds values

I need to a select statement that will pull the qty together for the same cust_id

what I have...
log_id           qty        cust_id
1047      1          36134
1048      1          36134
1049              4          3332

result...
cust_id     qty
36134       2
3332         4
0
sl1nger
Asked:
sl1nger
1 Solution
 
SwindleCommented:
SELECT sum(qty), cust_id
FROM yourtable
GROUP BY cust_id
0
 
SQL_SERVER_DBACommented:
SELECT
     SUM(QTY) TOTALQTY,
     CUST_ID
FROM
     <table_name>
GROUP BY
     CUST_ID
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now