I\'m trying to get this to display only the plan_id that appears the most often
ID: 3687909 • Letter: I
Question
I'm trying to get this to display only the plan_id that appears the most often in the table using a single sql statement, everything below works but I have no idea what to do next to achieve my goal.
SELECT financing_plans.loan_type,
financing_plans.institution,
COUNT(sales_financings.plan_id) AS count_plan_id
FROM financing_plans,
sales_financings
WHERE financing_plans.plan_id = sales_financings.plan_id
GROUP BY financing_plans.loan_type,
financing_plans.institution
ORDER BY count_plan_id DESC
The actual problem is below:
Via a single SELECT query display the institution and loan type of the financing plan that was used for the most sales. Show the SQL statement you used and the results returned by Oracle from executing your SQL statement right after the statement.
Explanation / Answer
SQL statement :
SELECT financing_plans.plan_id FROM financing_plans, sales_financings WHERE financing_plans.plan_id = sales_financings.plan_id GROUP BY financing_plans.loan_type, financing_plans.institution;
This SQL statement shows the Plan_id of financing_plan ,where the institution and loan type of the financing plan that was used for the most sales