Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sql statement mysql

Posted on 2011-03-07
3
Medium Priority
?
310 Views
Last Modified: 2012-05-11
Sql statement on my sql below is work  but i not under stand

1   why no have comma  betaween SUM(quantity) SUMClaim


SELECT productcode, SUM(quantity) SUMClaim

2 i not under stand all entire statement
UPDATE product
JOIN
(
SELECT productcode, SUM(quantity) SUMClaim
FROM claimdetail
GROUP BY productcode
) claims on claims.productcode = product.ProductId
SET product.ProductQuantity = product.ProductQuantity - claims.SUMClaim

Open in new window

0
Comment
Question by:teera
3 Comments
 

Author Comment

by:teera
ID: 35064575
UPDATE product
JOIN
(
SELECT productcode, SUM(quantity) SUMClaim
FROM claimdetail
GROUP BY productcode
) claims on claims.productcode = product.ProductId
SET product.ProductQuantity = product.ProductQuantity - claims.SUMClaim
0
 
LVL 23

Accepted Solution

by:
OP_Zaharin earned 2000 total points
ID: 35064673
SUM(quantity) SUMClaim - no comma means that 'the sum for quantity' header title will be displayed as SUMClaim

(check the sql result and the header title, you will find a name with SUMClaim)
0
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 35064714
Sumclaim is just the name you are giving to the sum of quantity. The 'as' is optional.
Select sum(quantity) as sumclaim
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month6 days, 22 hours left to enroll

782 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