I Need Help writing all these SQL Problems ASAP!! 1. Write an SQL query for the
ID: 3720946 • Letter: I
Question
I Need Help writing all these SQL Problems ASAP!! 1. Write an SQL query for the HAPPY INSURANCE Database that will retrieve the name of each agent that has a rating lower than 100, as well as whose name starts with an “A”2.Write an SQL query for the HAPPY INSURANCE database that will list the client name and agent name for each client who does Not have a spouse.
3.Write an SQL query for the HAPPY INSURANCE Database that will display the average agent year of hire for all agents.
4. Write an SQL query for the HAPPY INSURANCE Database that will for each agent, the agents id, name and area along with the number of clients that agent had with the column header “Client Count”.
5.write an SQL for the HAPPY INSURANCE Database that will display the name of each client of the agent that has been with the company longest.
6. Write an SQL query for the HAPPY INSURANCE Database that will for each agent listcthe agents id, agents name, area name, and the clients of that agent. The results should be listed by agent name, area name, and client name.
Explanation / Answer
1. select AgentName from AGENT where AgentRating<100 and AgentName like 'A%';
2.select ClientName,AgentName from CLIENT c,AGENT a where c.ClientAgent=a.AgentID and c.ClientSpouseName IS NULL;
3.select AgentID, avg(AgentYearOfHire) from AGENT group by AgentID;
4. select AgentID,AgentName,AreaName,count(ClientID) from AGENT a,CLIENT c,AREA ae where c.AgentArea=ae.AreaID and c.ClientAgent=a.AgentID group by AgentID;
5.select ClientName,min(AgentYearOfHire) from CLIENT,AGENT where ClientAgent=AgentID group by ClientName having min(AgentYearOfHire);
6.select AgentID,AgentName,AreaName,ClientName from AGENT,CLIENT,AREA where AgentArea=AreaID and ClientAgent=AgentID;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.