Guest User

Guest User

  • Tech Writer
  • 49
  • 2.6k

Not getting expected output while using PIVOT in Sql Server

Oct 13 2016 2:31 AM
Following is my SqlServer table<br /><div><img src="/forums/uploadfile/3399e6/10132016020512AM/Table.PNG" alt="" /></div><div>&nbsp;I expected result as below</div><div><img src="/forums/uploadfile/3399e6/10132016020512AM/Expected Output.PNG" alt="" /> In above output i want count of student who paid their fees. at the same time i want to group that count by fee_type, date and class_division.</div><div>&nbsp;</div><div>I am using PIVOT for achieve this result.</div><div>Following is my query</div><div><img src="/forums/uploadfile/3399e6/10132016020512AM/Sql query.PNG" alt="" />&nbsp;</div><div>&nbsp;But not getting result as i expected.</div><div><img src="/forums/uploadfile/3399e6/10132016020512AM/Sql Output.PNG" alt="" />&nbsp;</div><div>&nbsp;This is what i am getting after execution of my query. which is totally&nbsp; wrong.</div><div>&nbsp;</div><div>Please let me know if there is any solution to get expected result.</div><div>&nbsp;</div><div>Thanks</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div> </div>

Answers (2)