Question : MULTIPLE CTE

Hi All,

I have query below.
Could I filter and join Table THPOJUAL with TDPOJUAL inside CTE?

Because without filtering inside CTE,  it will fetch all of records.

How to solve this problem?

Thank you.



1:
2:
3:
; WITH THPOJUAL AS (SELECT *  FROM THPOJUAL2008 AS A UNION ALL SELECT *  FROM THPOJUAL2009 AS A UNION ALL SELECT *  FROM THPOJUAL2010 AS A )  ,  TDPOJUAL AS (SELECT *  FROM TDPOJUAL2008 AS B UNION ALL SELECT *  FROM TDPOJUAL2009 AS B UNION ALL SELECT *  FROM TDPOJUAL2010 AS B ) 

 SELECT SUM( (B.Harga_Net / B.Qty_PO)  * (B.Qty_SJ - B.Qty_Fkt) ) AS NilaiPO  FROM THPOJUAL AS A LEFT JOIN TDPOJUAL AS B ON A.Nomor_OA = B.Nomor_OA WHERE A.CustCode = 'ADJ04' AND B.Qty_SJ > B.Qty_Fkt

Answer : MULTIPLE CTE

Depending on you comfort level with Active Directory, it can be done in as little as 4-6 hours.  The first time may be a little longer.  I heard from people who are not well versed in servers taking a couple of days to complete the process.  The steps are very well documented, so if you follow them exactly, you should not have a problem.  The kit is a download from their site, so you can start reviewing the materials right away before you start the project.  This method has been around for many years now, and is a very safe and predictable way to migrate SBS 2003 from one server to another.  There is no better or fail safe way.  I have been using it since 2005 and have done it about 30 times.  The best $200 I ever spent!
Random Solutions  
 
programming4us programming4us