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:
01520896
Views:
22
>>>>>What numbers do you see for the records that have the same Precinct? The Rn should be the same, if not, then they are not identical.
>>>>
>>>>
>>>>1 through 27 - the same number of precints for that county
>>>
>>>I think we may misunderstand each other now. Do you have the same precinct for that county? If you do, do these records have the same Rn number or this number is different?
>>>
>>>You said originally that you're seeing duplicates. Did I understand you correctly? With DENSE_RANK() you're not supposed to get duplicates unless they only look like duplicates but not really duplicates. This is what I'm trying to determine now.
>>
>>
>>They allappear the same to me.
>>
>>There are multiple precincts in each county, The out put needs to show only aone insance of each precinct in each county. I other words, under the Adams count column each precincnt should only appear once.
>
>Suppose, you have
>
>Adams county
>
>Pr1
>Pr2
>Pr3
>
>Do you want to show all 3 of them or you only want to show Pr1?
>
>If the later, then just add
>
>set SQL = 'SELECT * from (....) X PIVOT (max(Precinct) for MailCounty IN (' + @Cols + ')) pvt WHERE Rn = 1'
>
>If you want to see all 3 of them, then no changes are required in the original code. However, if
>they looked like
>Pr2
>Pr2
>
>but when you run the code I asked you to run and the Rn was different for these apparently same Precincts, then it means, that they are not the same - there may be difference you can not see (invisible characters)). It will be a bit tricky to get rid of them, although not too tricky.


Each county has multiple occurances of precincts. The final result should be a table with one column for each county. In each column should be only one occurance of each precinct in tht county.

So, for Adams, assume it had:
ADAMS
=======
PRE 1
PRE 1
PRE 1
PRE 2
PRE 2
PRE 3
PRE 3
PRE 3
PRE 4
the result should be
ADAMS
=======
PRE 1
PRE 2
PRE 3
PRE 4
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