title: How can handle this ERROR 1242 (21000): Subquery returns more than 1 row
body: <p>Hello everyone I am having issue with SQL query, have googled a lot but couldnt find any solution. here is my code:</p>
  
  <pre><code> SELECT (SELECT ltp 
           FROM eod_stock  
           WHERE company_id IN (1,2) 
               AND entry_date = '2013-09-24') AS b,
          (SELECT ltp 
           FROM eod_stock  
           WHERE company_id IN (1,2) 
               AND entry_date = '2013-09-25') AS e,
          CAST(((SELECT ltp 
                 FROM eod_stock  
                 WHERE company_id IN(1,2) 
                     AND entry_date = '2013-09-25') -
                (SELECT ltp 
                 FROM eod_stock  
                 WHERE company_id IN (1,2) 
                     AND entry_date = '2013-09-24')) /
                (SELECT ltp  
                 FROM eod_stock  
                 WHERE company_id IN (1,2) 
                     AND entry_date = '2013-09-25')*100 
               AS DECIMAL(10,2)) AS c;
  </code></pre>
  
  <p>it gives me error</p>
  
  <pre><code>ERROR 1242 (21000): Subquery returns more than 1 row
  </code></pre>
  
  <p>I understand the error cause my query should return more than 1 row as i am passing 2 company but i need all companies ltp, that i mentioned in my query. The result is need is like:</p>
  
  <pre><code>+--------+--------+--------+
  | b      | e      | c      |
  +--------+--------+--------+
  | 460.00 | 338.00 | -36.09 |
  +--------+--------+--------+
  | 320.00 | 488.00 |  34.42 |
  +--------+--------+--------+
  </code></pre>
  
  <p>can anyone suggest how can i get multiple result like this from my query? caz i have to pass more than 1 company id in my query.</p>
  
  <p>Table structure:  </p>
  
  <pre><code>+-----------------+------------------+------+-----+---------+-------+
  | Field           | Type             | Null | Key | Default | Extra |
  +-----------------+------------------+------+-----+---------+-------+
  | company_id      | varchar(30)      | NO   | PRI | NULL    |       |
  | entry_date      | date             | NO   | PRI | NULL    |       |
  | entry_timestamp | int(10) unsigned | NO   |     | NULL    |       |
  | open            | decimal(16,2)    | NO   |     | NULL    |       |
  | high            | decimal(16,2)    | NO   |     | NULL    |       |
  | low             | decimal(16,2)    | NO   |     | NULL    |       |
  | ltp             | decimal(16,2)    | NO   |     | NULL    |       |
  | ycp             | decimal(16,2)    | NO   |     | NULL    |       |
  | cse_price       | decimal(9,2)     | NO   |     | NULL    |       |
  | cse_volume      | decimal(18,2)    | NO   |     | NULL    |       |
  | total_trade     | int(30)          | NO   |     | NULL    |       |
  | total_volume    | int(30)          | NO   |     | NULL    |       |
  | total_value     | decimal(18,4)    | NO   |     | NULL    |       |
  +-----------------+------------------+------+-----+---------+-------+
  </code></pre>