Link to home
Create AccountLog in
Avatar of MrTV
MrTVFlag for Thailand

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
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

Avatar of MrTV
MrTV
Flag of Thailand image

ASKER

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
Avatar of OP_Zaharin
OP_Zaharin
Flag of Malaysia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Aaron Tomosky
Sumclaim is just the name you are giving to the sum of quantity. The 'as' is optional.
Select sum(quantity) as sumclaim