|
-
Trouble with complex SQL query - multiple tables - pppor design
I am having trouble creating the appropriate query to pull information from three different tables. Admittedly the database design IMHO is horrible but it cannot be changed as it is part of a paid product that won't budge or even offer help with what I am doing. I am trying to run some reporting off this database.
Tables are as follows:
trans, trans_date, trans_details
Plans Table
NAME......ID.....REP
Name1.....1......Tom
Name3.....3......Jim
Name2.....4......Bob
Trans Table
planid...transid
123.......456
124.......459
125.......460
Trans_Date Table
transid date........zassocrow
456......1-1-2009......1
459......2-1-2009.......2
460......12-1-2008.....3
trans_details table
transid....amount....code....repamount.....zassocrow
456 .......$1234 .......XYZ ......$123 ..........1
459 .......$2345 .......ZYX ......$222 ..........2
460 .......$1122........ZYC ......$111 .........3
Plan holds information about the client that purchased the plan.
Trans_details holds dates and amount of a transaction but has no reference to the client (Client information is in Plan table).
I need to pull all transactions between a certain date for a certain sales rep but I also need to display the client information (from Plan table)
This thing has been killing me because the tables are several hundred thousand rows and I just can't seem to get a query that returns the correct data without returning millions of rows.
Similar Threads
-
By awyeah in forum Database
Replies: 1
Last Post: 07-13-2008, 11:35 AM
-
By cyman73 in forum VB Classic
Replies: 2
Last Post: 11-18-2005, 12:10 AM
-
By dhaya in forum Database
Replies: 11
Last Post: 08-25-2003, 05:24 PM
-
By Santosh in forum Database
Replies: 3
Last Post: 02-28-2001, 02:36 AM
-
Replies: 4
Last Post: 01-18-2001, 09:00 PM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks