ok great...i am sure it will more efficient than what you actually have now
1. first create views for the indiviual queries you are having...for example...
Code:
Create View as myview1
AS
SELECT distinct blah, blah1...and so on...
basically you can have any select statement, may be you just dump the one you are using now...you can also use stored procedures instead of views...which ever is comfortable for you...here is the syntax of stored procedure...
Code:
Create Procedure mystoredproc1
AS
SELECT distinct blah, blah1...and so on...
very similar syntax...
ok now you have lets 3 views set up...
then you can just do a select statement on top of these views to get the data you want...something like...
SELECT blah from myview1
i mean...to make it clear for you...each view is like a table on which you can do a select statement...BUT INSTEAD OF THE ORIGINAL TABLES THESE VIEWS HAVE CALCULATED FIELDS....and on top of these views you create another calculated field that gives you rating...
for example...
let my original table is
id | salary | county
____________________
1 | 10 | county1
2 | 20 | county2
3 | 15 | county3
4 | 30 | county4
i will create a view now on top of it...that might give me something like...
id | salary | county
____________________
1 | 100 | county1
2 | 200 | county2
3 | 60 | county3
4 | 150 | county4
ie...if it is county1 and county2 then i multiplied with 10 and it is county3 then i mutiplied with 4 and if it county4 then i multiplied with 5...of course i created this view using Case or If statements...
now on top of this i can do the rating query which will give something like this...
id | salary | county | Rank
___________________________
1 | 100 | county1|101
2 | 200 | county2|202
3 | 60 | county3| 63
4 | 150 | county4|153
just adding id with salary - some formula for rank...
this example is just illustrate the whole process...
let me know if you have any questions...
-DNG