2
Answers

two select common used in store procedure but result is one

nitish rai

nitish rai

6y
151
1
ALTER Proc [dbo].[ProCreateBottleline1POSIMATfinal]
(
@StartDate date,
@EndDate Date
)
As
begin
select * from FloatTable
where cast(DateAndTime as date) between @StartDate and @EndDate
SELECT [0]as [ActivePowerKW],[3]as [PowerFactor],[1]as [CurrentAmp] ,[4] as [VoltageV],[2]as [FrequencyHz],DateAndTime FROM
(
SELECT TagIndex,Val,DateAndTime,Row_Number() Over(partition by TagIndex order by TagIndex,DateAndTime) As ColumnSeries FROM FloatTable
)Temp
Pivot
(
max(Val) For TagIndex in ([0],[3],[1],[4],[2])
)Piv
End
-----------------exec ProCreateBottleline1POSIMATfinal @StartDate='2018-01-04',@EndDate='2018-01-05'

Answers (2)