Question
I would like to make a select statement using CASE statement and INNER JOIN. But I don't know what is wrong that is giving me
I would like to make a select statement using CASE statement and INNER JOIN. But I don't know what is wrong that is giving me error: "ORA-00918: column ambiguously defined 00918. 00000 - "column ambiguously defined"
This is what I have so far: SELECT custname, CASE WHEN COUNT(custname) = 1 THEN 'One-time buyer' WHEN COUNT(custname) = 2 THEN 'Two-time buyer' ELSE 'Frequent buyer' END AS "Customer Classification" FROM si.saleinv INNER JOIN si.car ON saleinv.custname = car.custname GROUP BY custname HAVING LOWER (carmake) = 'mercedes';
When I try without the inner join it works... but then I can't select only the buyers of mercedes carmake.
SELECT custname, CASE WHEN COUNT(custname) = 1 THEN 'One-time buyer' WHEN COUNT(custname) = 2 THEN 'Two-time buyer' ELSE 'Frequent buyer' END AS "Customer Classification" FROM si.saleinv GROUP BY custname ;
How can I fix it? (Oracle database)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started