This task should be done in Access with 1 query. There are 3 tables:
address {id, address, city, postalcode, country, supplierid}supplier {supplierID, supplierName, nameid}contactname {nameid, firstname, lastname, phone}
I need to create query, that results with the following table:
{country, supplierNumber, supplierName, firstname, lastname, phone}
Where supplierNumber is number of companies in specific country.
For countries with only 1 company country, supplierName, firstname, lastname, phone fields must be filled; with 2 or more companies country, supplierNumber fields must be filled.
So I had straightforward idea to use:
SELECT COUNT() ...
FROM ... INNER JOIN ... ON ...
HAVING COUNT() ...
GROUP BY ...
UNION
...
But I got stucked with a lot of problems. GROUP BY requires all fields that SELECT takes because of COUNT(); UNION requires equal number of fields in tables, so maybe the second table should be complemented with NULL fields or something. So I have no idea, which way this task should be implemented. Please, help me.