OK guys embarrassing question. I need the SQL to for the following , to GROUP
Account_Ref,
Account,
AsOf,
AND SUM
BOPMV,
EOPMV,
Prod_Inflow,
Prod_Outflow
I keep messing with this and am doing something dumb....
Here is the query...
SELECT
Account_Ref,
Account,
AsOf,
0 as BOPMV,
Prod_EOPMV as EOPMV,
Prod_Inflow,
Prod_Outflow
FROM Source_Prod_Enhanced
UNION ALL
SELECT
Account_Ref,
Account,
PriorAsOf as AsOf,
Prod_BOPMV as BOPMV,
0 as EOPMV,
0 as Prod_Inflow,
0 as Prod_Outflow
FROM Source_Prod_PriorVal
Thanks and sorry for being dumb.
... and there is a second question. There are 4 fields that are always set to 0 on one side, which I'm only doing to support the merging of the 3 like GROUP fields into one record for each. The SUM function is just to support the grouping. Is there a better way to do this and/or one that will produce results faster? My UNIONs are not very clean and tend to run slow.
Thanks everyone for the help.
Account_Ref,
Account,
AsOf,
AND SUM
BOPMV,
EOPMV,
Prod_Inflow,
Prod_Outflow
I keep messing with this and am doing something dumb....
Here is the query...
SELECT
Account_Ref,
Account,
AsOf,
0 as BOPMV,
Prod_EOPMV as EOPMV,
Prod_Inflow,
Prod_Outflow
FROM Source_Prod_Enhanced
UNION ALL
SELECT
Account_Ref,
Account,
PriorAsOf as AsOf,
Prod_BOPMV as BOPMV,
0 as EOPMV,
0 as Prod_Inflow,
0 as Prod_Outflow
FROM Source_Prod_PriorVal
Thanks and sorry for being dumb.
... and there is a second question. There are 4 fields that are always set to 0 on one side, which I'm only doing to support the merging of the 3 like GROUP fields into one record for each. The SUM function is just to support the grouping. Is there a better way to do this and/or one that will produce results faster? My UNIONs are not very clean and tend to run slow.
Thanks everyone for the help.
Last edited: