我有SQL Server 2000
問題引用三列到同一列的另一個表,我需要從數據庫的報告。我有一個名爲Automation
的數據庫,它包含一組表來處理我們應用程序的票務處理查詢。在SQL Server 2000
我需要提取從數據庫的報告應包含票號和用戶信息喜歡誰已經進入,接受,編輯,審查了票。
我需要這些字段從數據庫
Ticketnumber
billnumber
companyname
enteredby(username)
entereddate
recievedby(username)
recieveddate
editedby(Employeename)
editeddate
reviewedby(ReviewerName)
revieweddate
postedby(Managername)
posteddate
我有三個表
1>VPP_VendorBilldetails
BillentryID | ticketnumber | billnumber | VENDORNAME,BILLNUMBER,COSTCENTERNAME,BILLAMOUNT,TICKETDATE,BILLDATE | companyID(not companyname) | billdate | Enteredby(userid)| entereddate | recievedby(userid) | recieveddate | editedby(userid) | editeddate | reviewedby(userid) | revieweddate | postedby(userid) | posteddate
2>Users
UserID | employeeID | employeename |loginID| Password | usertype | status
3>VPP_ClientCompanyDetails
:
companyid | companyname | companyaddress | status
我寫此查詢,但我對所有三個類別獲得相同的員工姓名:
SELECT CLIENTCOMPANYNAME, TICKETNUMBER,VENDORNAME,BILLNUMBER,COSTCENTERNAME,BILLAMOUNT,TICKETDATE,BILLDATE,
RECIEVEDDATE,EMPLOYEENAME AS EXECUTIVENAME,
VPP_VENDORBILLDETAILS.MODIFIEDDATE,
EMPLOYEENAME AS REVIEWERNAME,EMPLOYEENAME AS POSTEDBY,POSTEDDATE,ERRORCODE,
IMPACTCODE,ROOTCAUSE,REVIEWERREMARKS
FROM
VPP_VENDORBILLDETAILS
INNER JOIN
VPP_CLIENTCOMPANYDETAILS
ON VPP_VENDORBILLDETAILS.BILLENTEREDCOMPANYID = VPP_CLIENTCOMPANYDETAILS.CLIENTCOMPANYID
INNER JOIN USERS
ON VPP_VENDORBILLDETAILS.MODIFIEDBY = USERS.USERID
WHERE CONVERT(VARCHAR(12),CONVERT(DATETIME,POSTEDDATE,103),101)
BETWEEN CONVERT(DATETIME,CONVERT(VARCHAR(12),getdate()-7,100),101)
AND CONVERT(DATETIME,CONVERT(VARCHAR(12),getdate()-1,100),101)
AND VPP_CLIENTCOMPANYDETAILS.STATUS = 1 AND VPP_VENDORBILLDETAILS.STATUS = 1 AND USERS.STATUS = 1 AND ERRORCODE IS NOT NULL AND TALLYID IS NOT NULL
ORDER BY CLIENTCOMPANYNAME ASC
請檢查並幫助我在此
請幫我提取報告上述表格。
沒有努力或嘗試顯示。 – 2013-02-20 07:28:07
嗨米奇..這是我第一次登陸並問4個問題..請讓我知道我不得不提到? – 2013-02-20 07:36:44
簡單:向我們展示您的嘗試。 – 2013-02-20 07:37:20