Jump to content
vaaibhavmohan

syntax error

Recommended Posts

select A.country,count(A.CustomerID) as N
from 
     (select country,Count(CustomerID) as N1 from customers group by country) as A
left join 
    (select country,Count(CustomerID) as N2 from customers group by country) as B 
     on A.N1=B.N2

 

the error:it is not reading A.customerid 

Share this post


Link to post
Share on other sites

You did not select CustomerID from table A, so you cannot access it. Perhaps you actually want to select N1.

Share this post


Link to post
Share on other sites

Try updating the code like this :

select A.country, count(A.N1) as N
from 
     (select country,Count(CustomerID) as N1 from customers group by country) as A
left join 
    (select country,Count(CustomerID) as N2 from customers group by country) as B 
     on A.N1=B.N2 group by A.Country

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...