0

Please let me know why this query is not working together. They are working separately:

(  (select item_name,
           sum(p_qty)
      from stock 
     where p_date between '08/06/2010' and '08/07/2010'
  group by item_name) -
(   select item_name, 
           sum(p_r_qty)
      from stock 
     where p_r_date between '08/06/2010' and '08/07/2010' 
  group by item_name))
2
  • 2
    I'd like to help, but what are you trying to accomplish? Example data and expected output please. Commented Aug 8, 2010 at 4:46
  • what is that - you've got there? Are you trying to subtract the queries? Commented Aug 8, 2010 at 4:51

1 Answer 1

4
select item_name, 
           sum(p_qty) ,
           sum(p_r_qty)
      from stock  
     where p_date between '08/06/2010' and '08/07/2010' 
group by item_name

is this what you want ?

select item_name, 
           sum(p_qty)-sum(p_r_qty)
      from stock  
     where p_date between '08/06/2010' and '08/07/2010' 
group by item_name
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.