Click here to Skip to main content
15,868,004 members

Comments by Santosh kumar Pithani (Top 200 by date)

Santosh kumar Pithani 30-Jan-20 7:01am View    
Hello,your updating all records for "ReportTable" based on updated "SellTable" columns, i hope there is no addition queries its should be complete in single line
Santosh kumar Pithani 4-Sep-19 0:18am View    
Try to remove duplicates by using Rownumber function on (ClassID,FeePartID) still your not clear then its better to post Dummy data along with expected output.
Santosh kumar Pithani 3-Sep-19 5:46am View    
Hello nyt72, your simply updating all records without maintaining proper relation on derived and updated table, try to use merge for these type of task.
Santosh kumar Pithani 26-Aug-19 9:04am View    
Hello, i hope this problem will be overcome by using "on update cascade" foreign key reference and also write one stored procedure for updating old value to other column.
Santosh kumar Pithani 30-May-19 9:39am View    
CREATE TABLE #Test ( SubHeading_Name VARCHAR(500),Pointer_Id int,JV VARCHAR(100),JAN INT,FEB INT);
INSERT INTO #Test
VALUES
('Preparation & Planning',1,'JV1',4,2)
,('Preparation & Planning',2,'JV1',3,3)
,('Preparation & Planning',3,'JV1',2,2)
,('Preparation & Planning',4,'JV1',4,1)
,('Preparation & Planning',1,'JV2',4,2)
,('Preparation & Planning',2,'JV2',3,3)
,('Preparation & Planning',3,'JV2',2,2)
,('Preparation & Planning',4,'JV2',4,1)

SELECT
SubHeading_Name,Pointer_Id,
MAX(case WHEN JV='JV1' THEN CAST(JAN AS Varchar(10)) END)+' '+
MAX(case WHEN JV='JV2' THEN CAST(JAN AS Varchar(10)) END) AS JAN,
MAX(case WHEN JV='JV1' THEN CAST(FEB AS Varchar(10)) END)+' '+
MAX(case WHEN JV='JV2' THEN CAST(FEB AS Varchar(10)) END) AS FEB
FROM #test GROUP BY SubHeading_Name,Pointer_Id