Query on three tables

Results 1 to 2 of 2

Thread: Query on three tables

  1. #1
    Join Date
    Dec 1969

    Default Query on three tables

    Hi,<BR><BR>I was wondering what SQL to use that will return 2 columns from a company table and the number of occurences of that company in two data tables. The key in all three is company_no. I think I need to use a group statement but i&#039;m not sure how to use it..<BR><BR>Any help is appreciated.<BR><BR>Thanks,<BR>Jo

  2. #2
    Join Date
    Dec 1969

    Default RE: Query on three tables

    Simple subquery?<BR><BR>SELECT C.Company_No, C.CompanyName,<BR> (SELECT COUNT(*) FROM Table1 T1 WHERE T1.Company_No=C.Company_No) AS Table1Count,<BR> (SELECT COUNT(*) FROM Table2 T2 WHERE T2.Company_No=C.Company_No) AS Table2Count<BR> FROM Companies C<BR><BR>??<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts