I’m working on my homework and am having trouble figuring out the correct syntax for the “NOT IN” functionality.
The database is a small insurance database (carriers, members, employers, plans) made up for this assignment. I am supposed to “List ALL carriers and the count of plans they have. (use either the right or left join). List the carrier_id, carname, and the count of plans.”
This is what I have written as of right now:
SELECT carrier_id, carname, count(*) AS NoPlans
FROM carriers RIGHT JOIN plans
ON carriers.carrier_id = plans.carrierid;
This throws the “not a single-group group function” error when I try to run it, but that’s because I think it’s looking for a WHERE clause, and I don’t know what the condition should be.
Carrier table structure:
Name Null Type
------------------------------ -------- -----------
CARRIER_ID NOT NULL CHAR(4)
CARNAME CHAR(35)
CARADDRESS CHAR(50)
CARCITY CHAR(30)
CARSTCODE CHAR(2)
CARZIP CHAR(10)
CARPHONE CHAR(10)
CARWEBSITE CHAR(255)
CARCONTACTFIRSTNAME CHAR(35)
CARCONTACTLASTNAME CHAR(35)
CARCONTACTEMAIL CHAR(255)
11 rows selected
Plans table structure:
Name Null Type
------------------------------ -------- -------------
PLANID NOT NULL NUMBER
PLNDESCRIPTION CHAR(35)
PLNCOST NUMBER(8,2)
CARRIERID CHAR(4)
4 rows selected
1 Answer