Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

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 ASP Free Forums Sponsor:
  #1  
Old August 19th, 2005, 10:22 AM
Princess Zea Princess Zea is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 97 Princess Zea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 38 m 3 sec
Reputation Power: 4
calcuation problem

I need some help into how to approach this problem I have 4 tables and based on the results in table A and B I need to do a query that will first take the name of the hobby in table A and match them with each customerid hobby in Table C.


The table above is the Hobbies table A,

Hobbyid Clientid hobbyname statename
1 1 swimming GA
2 1 jogging CO
3 1 dancing NY
4 1 swimming SC
5 2 swimming NY
6 3 swimming NY


table B is just a sample of the income table

B
hobbyid minsalary(10) expectedsal(10)

1 20000 100000
2 30000 400000
3 40000 500000
4 50000 600000
5 60000 200000
6 70000 700000



C
customerid State(10) cminsalary(5) cexpsalary(10) hobby
1 GA 20000 100000 swimming
2 NY 20000 30000 jogging
3 SC 30000 10000 dancing
4 CO 10000 30000 swimming





D
customerid stateSchools (10) StateBirth (20) PreferredState (10)
1 GA NY SC
2 NY NC GA
3 SC GA CO
4 CO CO GA


The tables already have the data and i would like to compare tables A and b with tables C and D so anything that is a state in table C and D is compared to the statename in table A and if the states match they will be given points I would then like the sum of the points , this category will be called geography. Table B minsalary and expectedsalary will be compared to table C CSalary and cexpsalary and put in a category called income a match will be given points. The points allocated are in brackets next to each field. Once I have a total points for each category I want to add them together and then add them to the table below.


TABLE E
customerid hobbyid finalscore


so if customerid 1 filled out a questionare
the hobby is swimming so the first thing will be to select all the hobbies that equal swimming from table A
once we have all the hobbies that = swimming ie( hobbyid 1,4,5,6) then the statename for ( hobbyid 1,4,5,6) will be compared to the values that have state in them in tables C AND D e.g stateSchools, StateBirth , PreferredState,etc and if the statename matches any of these feilds e.g table A Statename for hobbyid 1 GA is a match for customerid 1 stateschools GA so points will be allocated for a match and no points if no match. i then want to get the total points from all the questions and then put them in a table called total score (Table D) which will hold the custermerid, the hobbid and TOTAL



score so the results will look like this based on the mactches for each categorgy

TABLE D
customerid hobbyid score
1 1 40
1 4 10
1 5 10
1 6 10


the clientid and customerid are different.

thanks

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > calcuation problem


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 3 hosted by Hostway
Stay green...Green IT