Jump to content

SQL multiple columns from one


Go to solution Solved by SorryButImaNewbie,

Recommended Posts

Hello!

I tried to post my question to stackoverflow, but couldn't (unknown error massage) and w3school, but i still need to be validated there to ask.

I'm trying to create a query (in SQL developer), which retruns the number of emission classes of cars, grouped by country codes. I can create it for one emission class like this:
 
  SELECT
      DISTINCT country_code,
      COUNT(emission_class) EURO0
    FROM
      DB.CUSTOMER_VEHICLE
    WHERE emission_class = 'E0'
    GROUP BY country_code;
My problem that I don't know how to count for a new column for example EURO1 emission class, from the same column (emission_class). I thought that I should create views and then add them togeather, or UNION 6 different selects. Tried with where and having clauses.
 
I always seems to run into some kind of a problem, then i realize that when I'm not sure how to start something properly, I should ask/research it first, so here I'm.
 
Thank you for the insight! (sorry still quite fresh with SQL, thank god I haven't paid anything for university, the internet is actually way better :) )
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...