Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SQLWoman
Starting Member
1 Post |
Posted - 2012-08-08 : 10:54:36
|
| I am trying to find instances when IDCONTR_PART has two or more different IDCONTR_LEG associated with it. I have the query below but not sure if the syntax is right.SELECT IDEMPR_PART, IDCENT_PART, CODPROD_PART, IDCONTR_PART, COUNT(CONTR_LEG)FROM (SELECT IDEMPR_PART, IDCENT_PART, CODPROD_PART, IDCONTR_PART, IDCONTR_LEG + IDSCONTR_LEG AS CONTR_LEG, COUNT(CONTR_LEG) AS COUNTFROM SI_LACMISGROUP BY IDEMPR_PART, IDCENT_PART, CODPROD_PART, IDCONTR_PART, CONTR_LEGHAVING COUNT(CONTR_LEG) > 1)GROUP BY IDEMPR_PART, IDCENT_PART, CODPROD_PART, IDCONTR_PARTHAVING COUNT(CONTR_LEG) > 1; I can try to explain it:1. Define the Partenon Id = IDEMPR_PART + IDCENT_PART + CODPROD_PART + IDCONTR_PART2. Define the Legacy Id = IDCONTR_LEG + IDSCONTR_LEG3. Query for all the unique combinations of Partenon Id and Legacy Id4. From the results of this query, determine if there are multiple records for any Partenon Id5. If there are, they represent different Legacy Ids and we should research which ones are correct |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-08 : 11:02:26
|
| your intial explanation and latter one is contradictoryIDCONTR_PART has two or more different IDCONTR_LEG associated with itis not same as below3.Query for all the unique combinations of Partenon Id and Legacy Id4. From the results of this query, determine if there are multiple records for any Partenon Idas latter speaks about considering combination and then look for duplicate instancesso please confirm what exactly you're looking atformer or latter?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|