SELECT     d.cDealer_Code, d.cDealer_Name, A.cPact_No, A.cIn_Date
FROM         dbo.tbl_Work AS w INNER JOIN
                          (SELECT     cPact_No, cCorp_Code, dFrom_Date, dTo_Date, dRegDate, iAmount, cPact_Pos_Code, iPrice, cOper_Code, cIn_Date, cOut_Date
                            FROM          (SELECT     E.cPact_No, P.cCorp_Code, E.dFrom_Date, E.dTo_Date, P.dRegDate, E.iPrice, E.iAmount, E.cPact_Pos_Code, P.cOper_Code,
                                                                           P.cIn_Date, P.cOut_Date
                                                    FROM          dbo.tbl_Pact_Net AS P INNER JOIN
                                                                           dbo.tbl_Execute_Net AS E ON P.cPact_No = E.cPact_No
                                                    WHERE      (E.iAmount > 0) AND (E.dFrom_Date <= '2008-03-01') AND (E.dTo_Date >= '2006-01-01')
                                                    UNION
                                                    SELECT     E.cPact_No, P.cCorp_Code, E.dFrom_Date, E.dTo_Date, P.dRegDate, E.iPrice, E.iAmount, E.cPact_Pos_Code, P.cOper_Code,
                                                                          P.cIn_Date, P.cOut_Date
                                                    FROM         dbo.tbl_Pact_BaoJia AS P INNER JOIN
                                                                          dbo.tbl_Execute_BaoJia AS E ON P.cPact_No = E.cPact_No
                                                    WHERE     (E.iAmount > 0) AND (E.dFrom_Date <= '2008-03-01') AND (E.dTo_Date >= '2006-01-01')) AS AAA) AS A ON
                      A.cOper_Code = w.Work_code INNER JOIN
                      dbo.tbl_Dealer AS d ON A.cCorp_Code = d.cDealer_Code
WHERE     (w.Work_group IN
                          (SELECT     Work_group
                            FROM          dbo.tbl_WorkSub
                            WHERE      (cMemo = 0) AND (bBig = 1)))
posted on 2008-05-22 16:51  星答  阅读(139)  评论(0编辑  收藏  举报