SQL Query Help Please! Sql server on a Windows 2000 platform.
I have two tables that contain data. Table one has a column that is contained (foreign key) in table two. It also has a column NOT contained in table 2 that I need to multiply by the variable amount identified in table 2. The variable amounts are 12, 4, and 2. The variable held in table two is the multiplying factor.
IE:
all the 10's (from table 1) with a "Q" (from the foreign key) need to be multiplied by 4 from table 2 and then the results added up for a total.
Basically, all "10's" in table one that are connected to table 2 with a "Q" must be multipled by 4 and then summed.
The data figures from table 1 will vary but all of them that are identified by "Q" linked to table 2 as identified by "Q4" in the foreign key, must be multiplied by 4 and then added together.
What I want....
A stored procedure that will recognise an imput that will be a mix of A's, S's, Q's, and M's. It will multiply all the "Q's" by 4, sum the "Q's", multiply all the "S's" by 2, sum the "S's", multiply all the "M's" by 12, sum the "M's", Multiply all the "A's" by 1, sum the "A's" and then sum the sums of A's, S's, Q's, and M's.
Seems simple to some of you I know but mind boggling to me. A little help if you please!!
Thanks in advance. |