Link to home
Start Free TrialLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

SQL Server 2008 - Display record depending on status of data in another table

Trying to figure out how to write the SQL for the below scenario.

-  Lets say we have two tables Invoice and Timesheet.  
-  The Invoice table is used to pay all Timesheets.  
-  A user can work on the timesheet until they submit it.  Once it is submitted then it needs to be approved, rejected, or closed.

So, If the timesheet is new or open then I do not want the related invoice record to display.  It can only display if all associated timesheets are either approved, rejected, or closed.

Sample Table structure

-  Invoice.InvoiceID, Invoice.Status, Invoice.Amt, Invoice.PaidBy, Invoice.PaidOn

-  Timesheet.TimesheetID, Timesheet.InvoiceID, Timesheet.Status, TimeSheet.Rate, Timesheet.HoursWorked, Timesheet.Travel, Timesheet.Food, Timesheet.Gas, Timesheet.Hotel
ASKER CERTIFIED SOLUTION
Avatar of Thomasian
Thomasian
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial