Results 1 to 1 of 1
  1. #1
    Join Date
    May 2008
    Posts
    21

    Unanswered: Separate COUNTS using subqueries in on SELECT

    I'm using Informix 9.3. I'm selecting one column and am trying to return two columns using the two separate COUNTs as subqeuries.

    I'm trying to combine this query, which works fine by itself...

    SELECT sl_store,
    COUNT(sl_price) AS price
    FROM informix.sales
    WHERE sl_date between '05-25-2008' AND '05/31/2008' and sl_price >= '195'
    GROUP BY sl_store

    ...with this query that also works fine by itself.

    SELECT sl_store,
    COUNT(ALL sl_disreason) AS discount
    FROM informix.sales
    WHERE sl_date between '05-25-2008' AND '05/31/2008' and sl_disreason = '09'
    GROUP BY sl_store

    This is the latest script I've come up with but I can't get it working.

    SELECT sl_store,
    FROM informix.sales
    WHERE (SELECT COUNT(sl_price) AS price FROM informix.sales WHERE sl_date between '05/25/2008' AND '05/31/2008' and sl_price >= '195')
    AND (SELECT COUNT(sl_disreason) AS discount FROM informix.sales WHERE sl_date between '05/25/2008' AND '05/31/2008' sl_disreason = '12')
    GROUP BY sl_store
    Last edited by skisalomon77; 06-24-08 at 21:59.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •