If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Separate COUNTS using subqueries in on SELECT

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-24-08, 20:48
skisalomon77 skisalomon77 is offline
Registered User
 
Join Date: May 2008
Posts: 21
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 20:59.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On