hive_sales_sync_costarica/sql/docr/new_sales_specific.sql
Marvin Vallecillo a2663d15be First commit
2024-07-17 04:19:28 -06:00

14 lines
405 B
SQL

insert into pos.dbo.hive_sales
select
o.Location_Code, o.Order_Date, o.Order_Number, 0, null
from pos.dbo.Orders o
left join pos.dbo.hive_sales hs
on hs.Location_Code = o.Location_Code
and hs.Order_Date = o.Order_Date
and hs.Order_Number = o.Order_Number
where
o.Order_Date = ?
and o.Order_Status_Code = 4
and hs.Order_Number is null
and o.Order_Number = ?