title: How to write condition for subquery alias if having null value
body: <p>Here is my query,</p>
  
  <pre><code>SELECT
    `h`.`hotel_id`,
    (
    SELECT COUNT(room_id)
    FROM
      `abserve_hotel_rooms` AS `rm`
    WHERE
      `rm`.`adults_count` &gt;= "1" AND `rm`.`room_count` &gt;= "1" AND "Available" = IF(
        check_in_time = '2016-03-15',
        'Unavailable',
        (
          IF(
            '2016-03-15' &gt; check_in_time,
            (
              IF(
                '2016-03-15' &lt; check_out_time,
                'Unavailable',
                'Available'
              )
            ),
            (
              IF(
                '2016-03-22' &gt; check_in_time,
                'Unavailable',
                'Available'
              )
            )
          )
        )
      ) AND `room_prize` BETWEEN '174' AND '600' AND `rm`.`hotel_id` = `h`.`hotel_id`
  ) AS `avail_room_count`,
  (
  SELECT MIN(room_prize)
  FROM
    `abserve_hotel_rooms` AS `rm`
  WHERE
    `rm`.`adults_count` &gt;= "1" AND `rm`.`room_count` &gt;= "1" AND "Available" = IF(
      check_in_time = '2016-03-15',
      'Unavailable',
      (
        IF(
          '2016-03-15' &gt; check_in_time,
          (
            IF(
              '2016-03-15' &lt; check_out_time,
              'Unavailable',
              'Available'
            )
          ),
          (
            IF(
              '2016-03-22' &gt; check_in_time,
              'Unavailable',
              'Available'
            )
          )
        )
      )
    ) AND `room_prize` BETWEEN '174' AND '600' AND `rm`.`hotel_id` = `h`.`hotel_id`
  ) AS `min_val`
  FROM
    `abserve_hotels` AS `h`
  WHERE
    1 AND `city` = "madurai" AND `country` = "india"
  </code></pre>
  
  <p>It totally return one column values from my table <code>abserve_hotels</code> which is <code>hotel_id</code> with extra two alias columns such as <code>avail_room_count</code> and <code>min_val</code>..</p>
  
  <p>And I wrote those in a subquery..</p>
  
  <p>Here I have to check a condition <code>WHERE min_val IS NOT NULL</code> .i.e; if <code>min_val</code> having NULL value I have to restrict it</p>
  
  <p>How can I do this..</p>
  
  <p>And this is my table </p>
  
  <pre><code>hotel_id  avail_room_count  min_val   
  
  1             0                NULL
  2             0                NULL
  </code></pre>
  
  <p>Here I need to restrict these NULL values..</p>
  
  <p>Someone please help me ..</p>