Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing records from a SQL query
Message
De
21/01/2010 15:23:48
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Removing records from a SQL query
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01445297
Message ID:
01445297
Vues:
129
I have a SQL which returns some records. The result may look like this:
PrimaryKey PrimaryKeyChildTable ChildTableField
1                    1                  0
4                    5                  1
8                    6                  2
However, in some particular situations, depending on this big SQL syntax, we might end up with more than one records from the master table such as:
PrimaryKey PrimaryKeyChildTable ChildTableField
1                    1                  0
4                    5                  1
4                    6                  2
5                    8                  1
5                    8                  2
8                    6                  2
So, on top of the SQL syntax I have presently, I would like to add the necessary code so I would filter any record from a duplicate primary key at the child table level and only keep the record from the child table having ChildTableField=1. So, in such circumstances, when I would have two records from the child table in the query result, I would like to obtain this:
PrimaryKey PrimaryKeyChildTable ChildTableField
1                    1                  0
4                    5                  1
5                    8                  1
8                    6                  2
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform