是否在SQL Server中仅在一行中使用数据透视表?

是否在SQL Server中仅在一行中使用数据透视表?,sql,sql-server,Sql,Sql Server,这个查询返回四行中的每一行输出,但我只想返回一行,这可能吗?我为pivot表编写了这个过程。请告诉我任何一个 你不应该按BT.birdname和WHT.weight ALTER PROCEDURE [dbo].[K_RT_GetWareHousedailyReport] @fromdate datetime, @todate datetime, @branch varchar(50) AS BEGIN SET NOCOUNT ON; select M

这个查询返回四行中的每一行输出,但我只想返回一行,这可能吗?我为pivot表编写了这个过程。请告诉我任何一个

你不应该按
BT.birdname
WHT.weight

ALTER PROCEDURE [dbo].[K_RT_GetWareHousedailyReport] 
   @fromdate datetime,
   @todate datetime,
   @branch varchar(50)
AS
BEGIN
SET NOCOUNT ON;

    select 
       MR.Branch, convert(varchar(50), WH.date, 103) as Date,
       WH.NoofBirds, WH.Weight, WH.Meatyield,
       max(case when BT.birdname='Bone Less' then WHT.weight end) as BoneLess,
       max(case when BT.birdname='Skin Less' then WHT.weight end) as SkinLess,
       max(case when BT.birdname='Wings' then WHT.weight end) as Wings,
       max(case when BT.birdname='Liver' then WHT.weight end) as Liver
   from 
       K_RT_WarehouseDetails WH 
   inner join 
       K_RT_WarehouseTypeWeight WHT on WH.sno = WHT.ID
   inner join 
       K_RT_MasterRetailStores MR on MR.sno = WH.branch 
   inner join 
       K_RT_BirdType BT on BT.sno = WHT.[type] 
   where 
       MR.sno = @branch 
       and WH.date between @fromdate And @todate 
   group by 
       BT.birdname, WHT.weight, MR.branch, date, WH.noofbirds, WH.weight, WH.meatyield, WHT.ID 
   order by 
        WHT.ID
END

当前的输出是什么样子的?你想以哪列为轴心,以什么为基础?
....
group by MR.branch,date,WH.noofbirds,WH.weight,WH.meatyield,
WHT.ID 
order by WHT.ID