Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

Why does joint production occur?

Answered: 1 week ago