Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Do A Cross Tab
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01520803
Message ID:
01520894
Vues:
33
>>>>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.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform