以下是甲方旧报表的sql,他们是头部将finereport参数传给它,尾部直接调用数据库的参数,我要在sqlserver弄T+1再用KETTLE抽到MySQL中间库,最终是在帆软上调用这个mysql的中间库,难的是他们要求的时间维度有很多种,我应该怎么去改这个参数好呢? declare @startTime datetime ,@endTime datetime select @startTime='${startTime}' ,@endTime='${endTime}' --select @startTime = '2021-06-01', @endTime = '2021-06-10' SELECT f.FarmID, f.FarmName as '猪场', f.FarmName+line.LineName as '生产线', '' as '计划配种数', (select count(*) from ([Pigs].[T_Mating] as mating LEFT JOIN V_PigsArchives AS arc ON mating.PigsArchivesID = arc.PigsArchivesID LEFT JOIN Farm.T_Houses AS house ON house.HouseID = arc.HouseID) where mating.FirstMatingDate between @startTime and @endTime and house.ProductionLineID = line.ProductionLineID ) as '实际配种数', (select count(*) from ([Pigs].[T_PregnancyTest] as pre LEFT JOIN V_PigsArchives AS arc ON pre.PigsArchivesID = arc.PigsArchivesID LEFT JOIN Farm.T_Houses AS house ON house.HouseID = arc.HouseID) where pre.PregnancyTestDate between @startTime and @endTime and house.ProductionLineID = line.ProductionLineID and (pre.PregnancyTestResult = 2 or pre.PregnancyTestResult = 3) ) as '返情空怀', isnull((select count(*) from ([Pigs].[T_PregnancyTest] as pre LEFT JOIN V_PigsArchives AS arc ON pre.PigsArchivesID = arc.PigsArchivesID LEFT JOIN Farm.T_Houses AS house ON house.HouseID = arc.HouseID right join [Pigs].[T_Death] death on arc.PigsArchivesID = death.PigsArchivesID) where pre.PregnancyTestDate between @startTime and @endTime and house.ProductionLineID = line.ProductionLineID and (pre.PregnancyTestResult = 2 or pre.PregnancyTestResult = 3) and (death.DeathDate between @startTime and @endTime or arc.EliminatedDate between @startTime and @endTime)),0) as '妊娠期淘汰数', (select count(*) from ([Pigs].[T_PregnancyTest] as pre LEFT JOIN V_PigsArchives AS arc ON pre.PigsArchivesID = arc.PigsArchivesID LEFT JOIN Farm.T_Houses AS house ON house.HouseID = arc.HouseID) where pre.PregnancyTestDate between @startTime and @endTime and house.ProductionLineID = line.ProductionLineID and (pre.PregnancyTestResult = 4) ) as '流产' (select count(*) from ([Pigs].[T_ChangeHouse] as change LEFT JOIN V_PigsArchives AS arc ON change.PigsArchivesID = arc.PigsArchivesID LEFT JOIN Farm.T_Houses AS house ON house.HouseID = arc.HouseID) where change.ChangeHouseDate between @startTime and @endTime and house.ProductionLineID = line.ProductionLineID ) as '场内调动' FROM [Farm].[T_Farms] f right join [Farm].[T_ProductionLine] line on f.FarmID = line.FarmID where f.OrganID = 1 and f.IsDeleted=0 and f.FarmName!='虚拟公猪站' ${if(len(FarmID) == 0,""," and f.FarmID = '" + FarmID + "'")} ${if(len(ProductionLineID) == 0,""," and line.ProductionLineID = '" + ProductionLineID + "'")} group by f.FarmID,f.FarmName, line.LineName, line.ProductionLineID order by f.FarmID |