A
Addy
My MS SQL skills are under great test at the moment. I was wondering if
I could get some help on this problem.
So I have a Query which is pulling fields from different tables.
Below are the date elements of my query
FIELD NAMES
* Sum Of total Planned Sales (A sum of revenue from Table 1)
* Total Hrs (Total Air hours + Total Car hours + Total idle time) This
is also a summation field made up of three separate fields - Taken
from Table 2
* Functional ID - A ID assigned to a location - Taken from Table 1
I have data sets which look like the following
Functional ID Total Hours Sum of total Planned Sales
3344 66 $4500
3344 66 $4500
3346 66 $4500
3347 66 $4500
3347 66 $500
3349 66 $4500
This looks fine except when duplicate Funtcional IDs comes with a
diffent value for 'total planned sales. '
I want a query that will add the total hours per functional ID BUT if
there is a duplicate with a different 'Sum of Total planned Sales'
then I want the 'Total Hours' for the lower value of 'total
planned sales' equal to 0. Such is the case with Functional ID 3347.
I could get some help on this problem.
So I have a Query which is pulling fields from different tables.
Below are the date elements of my query
FIELD NAMES
* Sum Of total Planned Sales (A sum of revenue from Table 1)
* Total Hrs (Total Air hours + Total Car hours + Total idle time) This
is also a summation field made up of three separate fields - Taken
from Table 2
* Functional ID - A ID assigned to a location - Taken from Table 1
I have data sets which look like the following
Functional ID Total Hours Sum of total Planned Sales
3344 66 $4500
3344 66 $4500
3346 66 $4500
3347 66 $4500
3347 66 $500
3349 66 $4500
This looks fine except when duplicate Funtcional IDs comes with a
diffent value for 'total planned sales. '
I want a query that will add the total hours per functional ID BUT if
there is a duplicate with a different 'Sum of Total planned Sales'
then I want the 'Total Hours' for the lower value of 'total
planned sales' equal to 0. Such is the case with Functional ID 3347.