Note that there are some explanatory texts on larger screens.

plurals
  1. POreferencing three columns to same column in another table in sql server 2000
    text
    copied!<p>I have a question on <code>SQL Server 2000</code>, i need to get an report from database. I have database called <code>Automation</code> where it contains set of tables to handle the queries of ticketing process of our application.</p> <p>I need to extract a report from database that should contain <em>ticket number</em> and <em>user information</em> like who has entered, received, edited , reviewed that ticket.</p> <p>I need these fields from the database</p> <pre><code>Ticketnumber billnumber companyname enteredby(username) entereddate recievedby(username) recieveddate editedby(Employeename) editeddate reviewedby(ReviewerName) revieweddate postedby(Managername) posteddate </code></pre> <p>I have three tables <br> 1> <code>VPP_VendorBilldetails</code> </p> <pre><code>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 </code></pre> <p>2> <code>Users</code> <br></p> <pre><code>UserID | employeeID | employeename |loginID| Password | usertype | status </code></pre> <p>3> <code>VPP_ClientCompanyDetails</code> :<br></p> <pre><code>companyid | companyname | companyaddress | status </code></pre> <p>I have written this query, but I am getting same employee name for all three categories :</p> <pre><code> 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 </code></pre> <p>Please check it and help me on this</p> <p>Please help me to extract the report the above said tables.. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload