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
This query returns each row output in four rows but I want only in one row is it possible? I wrote this procedure for pivot table. Please tell me any one.
You shouldn't group by BT.birdname
and WHT.weight
....
group by MR.branch,date,WH.noofbirds,WH.weight,WH.meatyield,
WHT.ID
order by WHT.ID
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments