0

I can't identify the syntax mistake on this query, where´s the syntax mistake?

select c_name, c_address, c_mktsegment , count(*) as cnt customer join orders on c_custkey=o_custkey 
where
(c_name like %r% AND c_address like %a%) OR c_mktsegment like ='%t%'   
group by c_name, c_address, c_mktsegment having count(*)>2;
1
  • No FROM clause ? With a join ? Commented Sep 19, 2012 at 2:43

2 Answers 2

4

One error is you have missing quotes here:

(c_name like %r% AND c_address like %a%)

Should be:

(c_name like '%r%' AND c_address like '%a%')

Another problem mentioned in the comments is you missed the FROM keyword:

select c_name, c_address, c_mktsegment , count(*) as cnt customer 

Should be:

SELECT c_name, c_address, c_mktsegment , count(*) as cnt
FROM customer 

There may also be other errors. But you can be sure that both these problems are actually problems and they do need to be fixed. I'd strongly recommend that you fix them before further investigating any other problems.

Sign up to request clarification or add additional context in comments.

Comments

0

I am adding one more thing in the answer given by Mark Byers is that

you cannot use = with like operator

so you have to replace OR c_mktsegment like ='%t%' with OR c_mktsegment like '%t%'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.