MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2004, 03:35 PM
janteby janteby is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 janteby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Need help with Query

Hello,

I need help writing an Access Query.

I have 3 Tables,

Federal_Tax_Data,
State_Tax_Data,
Local_Tax_Data

All 3 have a field called EmplID.

What I need to get done is to Join the 3 on the EmplID, so that for all the Stat_Tax_Data records, the Employees Federal & Local Taxes appear.

I wrote this Query..

SELECT PERSONAL_DATA.*, STATE_TAX_DATA.*, FEDERAL_TAX_DATA.*, LOCAL_TAX_DATA.*
FROM ((STATE_TAX_DATA LEFT JOIN LOCAL_TAX_DATA ON STATE_TAX_DATA.EmplID=LOCAL_TAX_DATA.EmplID) LEFT JOIN FEDERAL_TAX_DATA ON STATE_TAX_DATA.EmplID=FEDERAL_TAX_DATA.EmplID) LEFT JOIN PERSONAL_DATA ON STATE_TAX_DATA.EmplID=PERSONAL_DATA.EmplID;

This works. How ever this is where I need the help...

In the State Tax Data there are multiple records for the same EmplID. Which is fine, but then for the Federal Tax Data & the Local Tax data it repeats the data for them. All I want is just 1 set of data for each of the Federal & Local Tax Data, still have the multiple for the State.

I hope I explained what I need to get done.

Here is some example data of what is happening & then what I want..

What is happening
------------------

EmplID StateTaxID Fed Tax Amout .....rest of fields
88501 1 80.00
88501 2 80.00


What I want
------------
EmplID StateTaxID Fed Tax Amout .....rest of fields
88501 1 80.00
88501 2

Any help would be greatly appreciated.

Thank you,
Jeff
Janteby@AOL.com

Reply With Quote
  #2  
Old December 1st, 2004, 03:35 PM
bocmaxima's Avatar
bocmaxima bocmaxima is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2004
Location: Tucson, Sonora
Posts: 1,322 bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level)bocmaxima User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 17 h 46 m 5 sec
Reputation Power: 23
Send a message via AIM to bocmaxima
You'd have to do that through a script of some kind.
If you tell SQL to fetch records, it will show all records and all fields. There's no way to get it to exclude certain fields in certain places the way you want it to because it just doesn't make sense logically.

Reply With Quote
  #3  
Old December 1st, 2004, 11:29 PM
trentmurray trentmurray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: Australia
Posts: 96 trentmurray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
what language are you using to display these results?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Need help with Query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT