Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

Limiting a left join to returning one result?

SELECT SUM(db.item_sales_nsv) as total FROM app_product_hqsales_otc as db 
LEFT JOIN app_item_target_otc as it ON 
db.id = (SELECT MAX(id) FROM app_item_target_otc  as ot WHERE id = db.id) 
and db.head_quarter = it.hqcode 
AND db.aaina_item_code = it.aaina_item_code AND db.month = it.month 
AND db.year = it.year
WHERE db.head_quarter = 'WIN001' AND db.month = '5' AND db.year = '2022' AND db.status = '1'
Source by www.wingsudaan.in #
 
PREVIOUS NEXT
Tagged: #Limiting #left #join #returning
ADD COMMENT
Topic
Name
2+1 =