Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Lighter Count Child-Parent?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Lighter Count Child-Parent?
Divers
Thread ID:
01382205
Message ID:
01382205
Vues:
74
In a one to many relationship between a parent and child table, what is the lightest way to count() the child table and return the parent description in one SQL statement?

Like:
TableParent = SomeID I, description C(50)
TableChild = pk I, SomeID I, OtherTablePK I)

My answer is this:
Select count(tablechild.someid) as itemcount, tableparent.description ;
  from tablechild ;
    left outer join tableparent ;
    on tablechild.SomeID=tableparent.SomeID ;
   group by tablechild.someid,tableparent.description
But it seems that I'm missing a "lighter" way to do this... am I?
Brandon Harker
Sebae Data Solutions
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform