title: Need to replace union in the SQL Query
body: <p><strong>I have to write a sql query</strong></p>
  
  <p>For each product, determine how many times it was bought in 2010, if at all.
  The result should be tuples of the form (product name, num times). If a product
  was not purchased at all in 2010, the second attribute should have a value of 0. 
  Don't use a UNION operator.</p>
  
  <p><strong>I have written the query using UNION but I have to write it without using UNION Operator</strong>    </p>
  
  <pre><code>SELECT p.product_name , COUNT(p.product_id)
    FROM product p JOIN buys b ON p.product_id = b.product_id
    WHERE b.year = 2010
    GROUP BY p.product_name
  UNION
   SELECT p.product_name, 0
    FROM product p JOIN buys b ON p.product_id = b.product_id
    WHERE b.product_id NOT IN (SELECT pr.product_id FROM product pr JOIN buys bu ON pr.product_id = bu.product_id WHERE bu.year = 2010)
    GROUP BY p.product_name;
  </code></pre>
  
  <p><strong>SCHEMA</strong></p>
  
  <pre><code>CREATE TABLE product(
    product_id NUMERIC(10) NOT NULL,
    product_name VARCHAR2(30) NOT NULL,
    product_price NUMERIC(10) NOT NULL,
    product_manufacturer VARCHAR2(30) NOT NULL,
    CONSTRAINT pr_pk PRIMARY KEY(product_id)
    );
  
  CREATE TABLE customer(
    customer_id NUMERIC(10) NOT NULL,
    customer_name VARCHAR2(30) NOT NULL,
    customer_age NUMERIC(10) NOT NULL,
    CONSTRAINT cu_pk PRIMARY KEY(customer_id)
    );
  
  CREATE TABLE buys(
    customer_id NUMERIC(10) NOT NULL,
    product_id NUMERIC(10) NOT NULL,
    month NUMERIC(2) NOT NULL,
    day NUMERIC(2) NOT NULL,
    year NUMERIC(4) NOT NULL,
    CONSTRAINT bu_pk PRIMARY KEY(customer_id, product_id),
    CONSTRAINT bu_fk1 FOREIGN KEY(customer_id) REFERENCES customer(customer_id),
    CONSTRAINT bu_fk2 FOREIGN KEY(product_id) REFERENCES product(product_id)
    );
  </code></pre>
  
  <p>Please help.</p>
  
  <p><strong>EDIT</strong>
  I just did the query</p>
  
  <pre><code>SELECT p.product_name , COUNT(b.customer_id)
    FROM product p LEFT OUTER JOIN buys b ON p.product_id = b.product_id AND b.year = 2010
    GROUP BY p.product_name;
  </code></pre>