Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 cross tab query Rate Topic Display Mode Topic Options
Author
 Message
 Posted Tuesday, January 15, 2013 1:01 AM
 Grasshopper Group: General Forum Members Last Login: Wednesday, August 28, 2013 2:45 AM Points: 19, Visits: 46
 hi all,how do i achieve this resultdivision 2012 2013 2014 2015 2016xyz 1 0 0 0 10abcd 11 0 0 0 9lmn 3 0 0 0 5i have data for year 2012 and 2016 there is no data for 2013,2014,2015.please help me achieve this.any help is highly appreciated.regardsfairozkhan
Post #1407061
 Posted Tuesday, January 15, 2013 1:34 AM
 Hall of Fame Group: General Forum Members Last Login: Today @ 3:31 AM Points: 3,590, Visits: 5,097
 Hi there!You've given us your expected results, but we need some DDL and test data to show you how to get them.This article provides excellent guidelines: Forum Etiquette: How to post data/code on a forum to get the best help My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!My thought question: Have you ever been told that your query runs too fast?My advice:INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.Need to UNPIVOT? Why not CROSS APPLY VALUES instead?Since random numbers are too important to be left to chance, let's generate some!Learn to understand recursive CTEs by example.Splitting strings based on patterns can be fast!
Post #1407076
 Posted Tuesday, January 15, 2013 2:03 AM
 Grasshopper Group: General Forum Members Last Login: Wednesday, August 28, 2013 2:45 AM Points: 19, Visits: 46
 data what i havedivision 2012 2013 2016xyz 1 0 10abcd 11 1 9lmn 9 4 11regards
Post #1407092
 Posted Tuesday, January 15, 2013 2:08 AM
 Hall of Fame Group: General Forum Members Last Login: Today @ 3:31 AM Points: 3,590, Visits: 5,097
 imfairozkhan (1/15/2013)data what i havedivision 2012 2013 2016xyz 1 0 10abcd 11 1 9lmn 9 4 11regardsI think I speak from experience when I say that people here really want to help you. However we're all volunteers. So to get good, tested code you really need to follow the guidelines that are in the article link that I posted. You have not, which leads me to believe you didn't read it. My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!My thought question: Have you ever been told that your query runs too fast?My advice:INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.Need to UNPIVOT? Why not CROSS APPLY VALUES instead?Since random numbers are too important to be left to chance, let's generate some!Learn to understand recursive CTEs by example.Splitting strings based on patterns can be fast!
Post #1407094

 Permissions