W
Warren
I have four queries below. 1,2,&3 work properly but 4 is working but not
properly - it is returning the whole table. Appreciate any suggestions.
(There are two tables: Comapny table (pk companyID) and associated Contact
table (fk CompanyID) that have field "Name" & field "Title" among other
fields.) THANKS!!!!
1) ==Query returning companies that have members with a title.
SELECT [Contact].[FirstName]+" "+[Contact].[LastName]+", "+[Contact].[Title]
AS NAME,
[Company].[CompanyName]
FROM Company INNER JOIN Contact ON [Company].[CompanyID]=[Contact].[CompanyID]
WHERE NOT IsNull([Company].[Address]) AND NOT IsNull([Contact].[Title]);
2) ==Query returning companies that have members with no title.
SELECT [Contact].[FirstName]+" "+[Contact].[LastName] AS NAME,
[Company].[CompanyName]
FROM Company INNER JOIN Contact ON [Company].[CompanyID]=[Contact].[CompanyID]
WHERE NOT IsNull([Company].[Address]) AND IsNull([Contact].[Title]);
3) ==Query returning companies that have no members at all.
SELECT "Managing Broker" AS NAME,
[Company].[CompanyName]
FROM Company LEFT JOIN Contact
ON [Company].[CompanyID]=[Contact].[CompanyID]
WHERE [Contact].[LastName] IS NULL;
4) ==THIS ONE IS EXECUTING BUT NOT RETURNING CORRECT RESULTS. Query should
return companies that have members but none with a management type of title.
In this task, “Broker Associate†is the only non-management title.
SELECT "Managing Broker" AS NAME,
[Company].[CompanyName]
FROM Contact INNER JOIN Company ON Contact.CompanyID = Company.CompanyID
WHERE (SELECT COUNT(*) FROM Contact WHERE ([Contact].[Title] <> "Broker
Associate" OR NOT IsNull([Contact].[Title])))>0
properly - it is returning the whole table. Appreciate any suggestions.
(There are two tables: Comapny table (pk companyID) and associated Contact
table (fk CompanyID) that have field "Name" & field "Title" among other
fields.) THANKS!!!!
1) ==Query returning companies that have members with a title.
SELECT [Contact].[FirstName]+" "+[Contact].[LastName]+", "+[Contact].[Title]
AS NAME,
[Company].[CompanyName]
FROM Company INNER JOIN Contact ON [Company].[CompanyID]=[Contact].[CompanyID]
WHERE NOT IsNull([Company].[Address]) AND NOT IsNull([Contact].[Title]);
2) ==Query returning companies that have members with no title.
SELECT [Contact].[FirstName]+" "+[Contact].[LastName] AS NAME,
[Company].[CompanyName]
FROM Company INNER JOIN Contact ON [Company].[CompanyID]=[Contact].[CompanyID]
WHERE NOT IsNull([Company].[Address]) AND IsNull([Contact].[Title]);
3) ==Query returning companies that have no members at all.
SELECT "Managing Broker" AS NAME,
[Company].[CompanyName]
FROM Company LEFT JOIN Contact
ON [Company].[CompanyID]=[Contact].[CompanyID]
WHERE [Contact].[LastName] IS NULL;
4) ==THIS ONE IS EXECUTING BUT NOT RETURNING CORRECT RESULTS. Query should
return companies that have members but none with a management type of title.
In this task, “Broker Associate†is the only non-management title.
SELECT "Managing Broker" AS NAME,
[Company].[CompanyName]
FROM Contact INNER JOIN Company ON Contact.CompanyID = Company.CompanyID
WHERE (SELECT COUNT(*) FROM Contact WHERE ([Contact].[Title] <> "Broker
Associate" OR NOT IsNull([Contact].[Title])))>0