Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

cross tab query Expand / Collapse
Author
Message
Posted Tuesday, January 15, 2013 1:01 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, January 15, 2013 2:02 AM
Points: 18, Visits: 42
hi all,
how do i achieve this result
division 2012 2013 2014 2015 2016
xyz 1 0 0 0 10
abcd 11 0 0 0 9
lmn 3 0 0 0 5

i 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.
regards
fairozkhan
Post #1407061
Posted Tuesday, January 15, 2013 1:34 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 6:03 AM
Points: 2,345, Visits: 3,191
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



No loops! No CURSORs! No RBAR! Hoo-uh!

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?

Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1407076
Posted Tuesday, January 15, 2013 2:03 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, January 15, 2013 2:02 AM
Points: 18, Visits: 42
data what i have
division 2012 2013 2016
xyz 1 0 10
abcd 11 1 9
lmn 9 4 11

regards
Post #1407092
Posted Tuesday, January 15, 2013 2:08 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 6:03 AM
Points: 2,345, Visits: 3,191
imfairozkhan (1/15/2013)
data what i have
division 2012 2013 2016
xyz 1 0 10
abcd 11 1 9
lmn 9 4 11

regards


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



No loops! No CURSORs! No RBAR! Hoo-uh!

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?

Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1407094
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse