MrTV
asked on
sql statement mysql
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
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Sumclaim is just the name you are giving to the sum of quantity. The 'as' is optional.
Select sum(quantity) as sumclaim
Select sum(quantity) as sumclaim
ASKER
JOIN
(
SELECT productcode, SUM(quantity) SUMClaim
FROM claimdetail
GROUP BY productcode
) claims on claims.productcode = product.ProductId
SET product.ProductQuantity = product.ProductQuantity - claims.SUMClaim