pr2-eugin
Super Moderator
- Local time
- Today, 10:38
- Joined
- Nov 30, 2011
- Messages
- 8,494
I have quiet a complicated Query at hand, with various calculations from several Sub Queries. I have a function that will get me a percentage based on two other calculated fields (revenue, annualized), that is passed to this function.
The function works amazing when numbers (15.63, 56.99) are passed to it. Or if I create a temp table from this complicated Query, then pass the now 'static' values to the function.
If I use it along side my complicated Query, the function seems to dish out the same percentage for all records.
For example, the query (for simplicity has the following).
The above is when I INSERT the complicated Query INTO the temp table.
If I run it as a normal Query and the result is,
Has anyone encountered this scenario a Query using a function that takes just two arguments returning a same value for every row?
The function works amazing when numbers (15.63, 56.99) are passed to it. Or if I create a temp table from this complicated Query, then pass the now 'static' values to the function.
If I use it along side my complicated Query, the function seems to dish out the same percentage for all records.
For example, the query (for simplicity has the following).
Code:
Agent | ImmRev | AnnRev | [COLOR=Red][B]Expected[/B][/COLOR]
---------+----------+-----------+-----------
AARON J | £15.80 | £44.20 | 0.1
AIMY | £32.47 | £76.60 | 0.4
AMBER B | £23.36 | £64.79 | 0.3
BILLIE | £11.55 | £24.83 | 0.05
CARLA | £17.08 | £48.39 | 0.2
CARYN W | £19.55 | £38.86 | 0.1
LISA | £18.83 | £39.84 | 0.1
LYNSEY | £18.89 | £51.23 | 0.2
SASHA U | £13.28 | £27.67 | 0.1
SHARNIE | £11.68 | £31.93 | 0.05
TARA | £11.87 | £30.37 | 0.05
TONI | £2.76 | £7.06 | 0.05
If I run it as a normal Query and the result is,
Code:
Agent | ImmRev | AnnRev | Actual
---------+----------+-----------+-----------
AARON J | £15.80 | £44.20 | 0.4
AIMY | £32.47 | £76.60 | 0.4
AMBER B | £23.36 | £64.79 | 0.4
BILLIE | £11.55 | £24.83 | 0.4
CARLA | £17.08 | £48.39 | 0.4
CARYN W | £19.55 | £38.86 | 0.4
LISA | £18.83 | £39.84 | 0.4
LYNSEY | £18.89 | £51.23 | 0.4
SASHA U | £13.28 | £27.67 | 0.4
SHARNIE | £11.68 | £31.93 | 0.4
TARA | £11.87 | £30.47 | 0.4
TONI | £2.76 | £7.06 | 0.4