troubleshooting Question

SQL Query Across Multiple Tables - Help

Avatar of Oscar Reyes
Oscar ReyesFlag for United States of America asked on
DatabasesMicrosoft SQL Server 2008Microsoft SQL Server
5 Comments1 Solution163 ViewsLast Modified:
Hello Experts!

I am OK with queries when it involves one table but not so great with multiple table and filtering. I have the following issue i hope someone can help me with:

Tables

tblAccounts
tblServiceOrders
tblInvoices

Relevant Fields
tblAccounts.AccountName
tblAccounts.AccountNumber
tblAccounts.AccountStatus
tblAccounts.AccountType

tblInvoices.InvoiceDate

tblServiceOrders.DateReceived

All Linked by AccountNumber field in all tables.


This is a customer database with all accounts and all their respective service requests and invoices. Looking for a query to provide a list of accounts that meet the following:

AccountStatus=Active
AccountType=Customer

And has had a service order or invoice in the last three years.


Also would like query for the inverse of this; list of accounts that DON’T meet this filter.

Thank you!
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros