Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Do A Cross Tab
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01520803
Message ID:
01520947
Views:
31
>>Thiss is what I got back
>>
>>
>>MailCounty	Precinct	cntDups
>>Adams	BERNE A                                           	267
>>Adams	BERNE B                                           	274
>>Adams	DECATUR 1                                         	301
>>Adams	DECATUR 2                                         	269
>>Adams	GENEVA                                            	191
>>Adams	MONROE B                                          	137
>>Adams	NO WASHINGTON                                     	124
>>Adams	SO MONROE                                         	207
>>Adams	UNION                                             	142
>>Adams	WABASH                                            	128
>>Adams	BERNE C                                           	299
>>Adams	BLUE CREEK                                        	91
>>Adams	DECATUR 3                                         	112
>>Adams	DECATUR 4                                         	207
>>Adams	DECATUR 5                                         	280
>>Adams	EAST ROOT                                         	205
>>Adams	FRENCH                                            	112
>>Adams	HARTFORD                                          	139
>>Adams	JEFFERSON                                         	69
>>Adams	KIRKLAND                                          	189
>>Adams	MONROE A                                          	21
>>Adams	Nottingham                                        	2
>>Adams	PREBLE                                            	170
>>Adams	SO WASHINGTON                                     	176
>>Adams	ST MARYS                                          	176
>>Adams	WEST ROOT                                         	168
>>
>
>Ok, it looks correct to me and the code should have
>
>Adams
>Berne A
>Berne B
>
>etc.
>
>Can you please show me the code you're using?
>
>What will this give you?
>
>SELECT * from (select MailCounty, Precinct, dense_rank() over (partition by MailCounty ORDER BY Precinct) as Rn
>from myTable) X PIVOT (MAX(Precinct) FOR MailCounty in ([ADAMS])) pvt
>
>?

This coide gives me 817 rows. Tnhe majority are NULL, so this list is NOT unique.
Rn	ADAMS
1	BERNE A                                           
2	BERNE B                                           
3	BERNE C                                           
4	BLUE CREEK                                        
9	DECATUR 5                                         
10	EAST ROOT                                         
11	FRENCH                                            
12	GENEVA                                            
17	MONROE B                                          
18	NEW ALBANY 37                                     
19	NO WASHINGTON                                     
20	Nottingham                                        
26	WABASH                                            
27	WEST ROOT                                         
28	NULL
29	NULL
34	NULL
35	NULL
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform