Search
 
SCRIPT & CODE EXAMPLE
 

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

PREVIOUS NEXT
Code Example
Sql :: query archive mode 
Sql :: less than date query sqlachemy 
Sql :: delete recurring email keep smallest id number 
Sql :: veri girme SQL 
Sql :: row_number equivalent MS Access for sequential id By Group (2) 
Sql :: oracle sqlp update amount / quantity 
Sql :: learnxinyminutes sql 
Sql :: error-expression-select-list-not-group-by-nonaggregated-column/ 
Sql :: how to use multiple transactions in sql server 
Sql :: mysql collation for case sensitive 
Sql :: multiple row join 
Sql :: NLS_NCHAR_CHARACTERSET 
Sql :: Getting error while running 50 MB script on SQL Server 
Sql :: NextBirthDayDate 
Sql :: greater than and less than in mysql query 
Sql :: sql gather statistics to increase performance 
Sql :: how do you execute the fragment or sqlBatch using scriptdom 
Sql :: T-SQL look for records with a hex value in a text field 
Sql :: como hacer una consulta en sql 
Sql :: mysql export data with a where clause 
Sql :: python sql last insertend 
Sql :: valadate mysql 
Sql :: mysql insert into select with recursive 
Sql :: joins vs includes 
Sql :: Split Column with delimiter into multiple columns 
Sql :: conditionla silme SQL 
Sql :: lesser than or equal to symbol in postgres 
Sql :: select statement to print shortest name 
Sql :: composite primary key sql 
Sql :: adding primery key constraint to a column 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =