Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi everyone,I need your help. Here are my problem.1. I have 3 tables(below table structure with sample data).TABLE A contact_id Name100 Sal Ferrulo 101 Dianne Deppen TABLE Bestab_id contact_id type_id1 100 11 100 22 100 32 100 42 101 12 101 2TABLE Cestab_id estab_name1 ABC Restaurant2 XYZ HotelI am looking for the following output to display in ASP.NET.Contact_id Name Work Place #of work place100 Sal Ferrulo ABC Restaurant 2 XYZ Hotel101 Diane Deppen XYZ Hotel 1I need your help and support.ThanksBOB
Kristen
Test
22859 Posts
Posted - 2005-07-01 : 01:30:58
Something like
SELECT A.contact_id, A.Name, A.estab_name, COUNT(*) AS [#of work place]FROM TABLE_A AJOIN TABLE_B BON B.contact_id = A.contact_idJOIN TABLE_C CON C.estab_id = B.estab_idGROUP BY A.contact_id, A.Name, A.estab_nameORDER BY A.contact_id, A.Name, A.estab_name