Home > database >  Refer to SQL server multi-table LianZha's problem, kneeling to kneel for it's too difficul
Refer to SQL server multi-table LianZha's problem, kneeling to kneel for it's too difficul

Time:09-16

As shown in figure... Join and group by I will only be associated with a product, and channels of warehouse and my brain is stupid, paste... Seek advice!!!!!!
To do the report, about the diagram below:

This is my individual affiliate product code:

CodePudding user response:

Warehouse and channel out... But why no data... Already input data
 
Select
Ws. CNCCode bandNCCode,
Ws. CNCName bandNCName,
Ws. CSpecs bandSpecs,
Ws. CModel bandModel,
Ws. CUnit bandUnit,
Ww. CWareName bandWareName,
Wc. CChannelName bandChannelName,
ISNULL (Dr. Warehouse today, 0) inToday,
ISNULL (dc. Today's outbound, 0) outToday
The from WI_SteelNC ws

Left the join
(select supachai panitchpakdi k_steelNC, h1 pk_warehouse, h1. Pk_channel, SUM (the CONVERT (a decimal (19, 2), b1. FTotalWeight)) AS today's library
The from WI_SteelNC s
Left the join EV_InStock_b b1 on b1. Pk_steelNC=supachai panitchpakdi k_steelNC
Left the join EV_InStock_h h1 on h1. IShId=b1. ISbId
Left the join WI_WareHouse w1 on w1. Pk_warehouse=h1. Pk_warehouse
Left the join WI_Channel c1 on c1. Pk_channel=h1. Pk_channel
Where datediff (day, CONVERT (datetime, h1. DNewDate, 120), the CONVERT (datetime, 'the 2020-09-14 17:20:52. 837', 120))=0 and h1. IState!=2
Group by supachai panitchpakdi k_steelNC, h1 pk_warehouse, h1. Pk_channel)
Dr On Dr. Pk_steelNC=ws. Pk_steelNC

Left the join
(select supachai panitchpakdi k_steelNC, h2 pk_warehouse, h2. Pk_channel, SUM (the CONVERT (a decimal (19, 2), b2. FTotalWeight)) AS today's outbound
The from WI_SteelNC s
Left the join EV_SaleWZ_b b2 on b2. Pk_steelNC=supachai panitchpakdi k_steelNC
Left the join EV_SaleWZ_h h2 on h2. WZhId=b2. WZhId
Left the join WI_WareHouse w1 on w1. Pk_warehouse=h2. Pk_warehouse
Left the join WI_Channel c1 on c1. Pk_channel=h2. Pk_channel
Where datediff (day, CONVERT (datetime, h2. DNewDate, 120), the CONVERT (datetime, 'the 2020-09-14 17:20:52. 837', 120))=0 and h2. The iState!=2
Group by supachai panitchpakdi k_steelNC, h2 pk_warehouse, h2. Pk_channel)
Dc on dc. Pk_steelNC=ws. Pk_steelNC

Left the join WB_StockNC WSN on WSN. Pk_steelNC=ws. Pk_steelNC
Left the join WI_WareHouse ww on ww. Pk_warehouse=WSN. Pk_warehouse
Left the join WI_Channel wc on wc. Pk_channel=WSN. Pk_channel
The order by the ws pk_steelNC, ww pk_warehouse, wc. Pk_channel

CodePudding user response:

  • Related