Tuesday, June 12, 2012

Standard Structure of SQL Statement


      SELECT C.Name
               , E.NameLast
               , E.NameFirst
               , E.Number
               , ISNULL(I.Description,'NA') AS Description
        FROM tblCompany AS C
         JOIN tblEmployee AS E
            ON C.CompanyID
              = E.CompanyID
  LEFT JOIN tblCoverage AS V
            ON E.EmployeeID
              = V.EmployeeID
  LEFT JOIN tblInsurance AS I
            ON V.InsuranceID
              = I.InsuranceID
      WHERE C.Name LIKE @Name
          AND V.CreateDate > CONVERT(smalldatetime,'01/01/2000')
  ORDER BY C.Name
               , E.NameLast
               , E.NameFirst
               , E.Number
               , ISNULL(I.Description,'NA')

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.