Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am executing sql query then output is not coming...

What I have tried:

;WITH CTE0
	
	as
(
select Salesorder.Orderno,SUM(OrderDetail.orderqty) as orderqty from OrderDetail 
inner join Salesorder  on Salesorder.OrderNO=OrderDetail.OrderNO
where Salesorder.Status='Open'
group by Salesorder.Orderno


),cte
as
(select Salesorder.Orderno,sum(Probale.Prdqty) as Produce from Probale
inner join Salesorder on Probale.orderno=  Salesorder.Orderno
where Salesorder.Status='Open'
group by Salesorder.Orderno)


(select orderqty,Produce,(orderqty-Produce) as Pending
 From cte1
 where orderqty+Produce+Pending<>0
 group by cte1.orderqty,cte1.Produce,cte1.Pending)
Posted
Updated 19-Jul-19 2:09am

We can't really help you - we have no access to your data at all, and it's normally relevant to SQL queries that don't work.

But ... Why are you naming your CTE cte0 and SELECTing from cte1 ?
 
Share this answer
 
Comments
akhter86 14-Jul-19 7:25am    
for avoid to duplicating
Maciej Los 14-Jul-19 7:42am    
Hawk eye!
akhter86 14-Jul-19 7:54am    
?
use cte0 instead of cte1
and the column Produce not contain in cte0
that are the issues fix that.
Then you will get the desired output.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900