-
Nested Query in ORACLE
Nested query is kicking my, well I won't say.
Here is the SQL: explanation of what I am trying to do follows the SQL:
select a.warehouse,
count(1) NUM_LINES, (select count(1) as zero_bal
FROM inventory b where b.warehouse='ACE' and
b.Q_RO > 0 and b.q_oh=0)
FROM inventory a WHERE a.warehouse='ACE'
and a.q_RO > 0 GROUP BY a.warehouse;
What I am trying (very uncessfully) is to get counts from a single table where
different conditions are met. In this eaample, I need to get acount of lines
in warehouse ACE where (Q_RO > 0) and a count of all the zero balance or Quanity on hand = 0. (Q_OH=0)
I am expecting something like
WAREHOUSE NUM_LINES ZERO_BAL
----------------------------------
ACE 960 27
I keep getting a not a group by Expression like below.
count(1) NUM_LINES, (select count(1) as zero_bal
*
ERROR at line 2:
ORA-00979: not a GROUP BY expression
Can anyone help a feller out??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|