PIVOT table only in one row in SQL Server?

santhosha
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.

valex

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SQL SERVER PIVOT TABLE One Row

From Dev

SQL Server pivot query returns only one row

From Dev

Table Pivot in SQL Server

From Dev

Pivot Table SQL Server

From Dev

Pivot Table SQL Server

From Dev

Pivot without aggregate with only one column in SQL Server

From Dev

How to query a SQL Server table in C# which results only in one single row?

From Dev

SQL server PIVOT with row grouping

From Dev

SQL PIVOT one column only

From Dev

SQL Server : pivot functionality, need to pivot a table

From Dev

sql server 2008 pivot table

From Dev

Pivot table in SQL Server 2008

From Dev

sql server 2008 pivot table

From Dev

SQL server Pivot Table issue

From Dev

Finding one row from pivot table

From Dev

SQL: Select only one row of table with same value

From Dev

SQL: Select only one row of table with same value

From Dev

SQL LIKE search error only on one row of table

From Dev

SQL Server how to update only one row in database?

From Dev

SQL Server: increment row number only one value

From Dev

sql server (Two tables and I want to display only one row)

From Dev

How to sum a specific row from one table to another in SQL Server

From Dev

Sum of row and column in SQL pivot table

From Dev

Sum of row and column in SQL pivot table

From Dev

SQL Server pivot calculate and convert row into column

From Dev

SQL Server, pivot unspecified number of columns and row

From Dev

SQL Server 2012 Dynamic Pivot Table with multiple subqueries and row 'headers' - can this be done?

From Dev

SQL JOIN to Only One Row

From Dev

Aggregation in dynamic pivot table in SQL Server 2012