Select 202006, Amy polumbo roductName, a.S pecName, Amy polumbo roceName, a.a mount, bp. Wprice
The from
(
Select
SpecName=(select TOP 1 BusinessName from openjson (RulesJosn) with (BusinessName nvarchar (50) '. $BusinessName, BusinessType int '$. BusinessType') where BusinessType=3)
, ProceName=(select TOP 1 BusinessName from openjson (RulesJosn) with (BusinessName nvarchar (50) '. $BusinessName, BusinessType int '$. BusinessType') where BusinessType=2)
, ProductName=(select TOP 1 BusinessName from openjson (RulesJosn) with (BusinessName nvarchar (50) '. $BusinessName, BusinessType int '$. BusinessType') where BusinessType=7)
The Amount=sum (Amount)
, ProceID=(select ProceID from openjson (GroupDetail) with (ProceID uniqueidentifier '$. ProceID'))
, SpecID=(select SpecID from openjson (GroupDetail) with (SpecID uniqueidentifier '$. SpecID'))
, ProductID=(select ProductID from openjson (GroupDetail) with (ProductID uniqueidentifier '$. ProductID'))
The from Device_IoTData
) a
Join Basic_ProceRule bp on bp. Amy polumbo roceID=proceID and a.S pecid bp.=specid and bp. Amy polumbo roductid=productId where
Amy polumbo roceID=bp. ProceID and a.S pecid bp.=specid and Amy polumbo roductid bp.=productId
GROUP BY Amy polumbo roductName, a.S pecName, Amy polumbo roceName, a.A mount
CodePudding user response:
If use function, the other should be in the group by column,Amount=sum (Amount)
Should add
The from iotdata group by RulesJosn
But this can and you want to the results of a query is different
Another query didn't add at the bottom of the top 1 May also complains
, ProceID=(select ProceID from openjson (GroupDetail) with (ProceID uniqueidentifier '$. ProceID'))
, SpecID=(select SpecID from openjson (GroupDetail) with (SpecID uniqueidentifier '$. SpecID'))
, ProductID=(select ProductID from openjson (GroupDetail) with (ProductID uniqueidentifier '$. ProductID'))
CodePudding user response:
Problem has been solved, thank you for your helpCodePudding user response:
Successfully solved, thank you