Hi,
I need to extract data from our data warehouse to import into a new program. The new program requires a csv file which contains a unique ID and a calculated figure. I have to write a query to calculate each value as they aren't stored anywhere in the DB (i.e. I can't just use SELECT field1 FROM table1) so I'm thinking it's going to have quite a performance impact.
My main problem is how do I link each individual query to it's correct unique ID (the new program has already been populated with these).
My thought was to do something like this:
The above is very simplified, but in essence I would be embedding a select statement for each one of the UniqueID's, which I'm not sure is very efficient.
Any ideas? Sorry if I've poorly explained what I need!
It's SQL Server 2005.
Cheers,
I need to extract data from our data warehouse to import into a new program. The new program requires a csv file which contains a unique ID and a calculated figure. I have to write a query to calculate each value as they aren't stored anywhere in the DB (i.e. I can't just use SELECT field1 FROM table1) so I'm thinking it's going to have quite a performance impact.
My main problem is how do I link each individual query to it's correct unique ID (the new program has already been populated with these).
My thought was to do something like this:
Code:
SELECT 'Key001' AS UniqueID
, (SELECT field1 * field2 / field3 FROM table1) AS CalculatedValue
UNION
SELECT 'Key002' AS UniqueID
, (SELECT field1 * field2 / field3 FROM table2) AS CalculatedValue
The above is very simplified, but in essence I would be embedding a select statement for each one of the UniqueID's, which I'm not sure is very efficient.
Any ideas? Sorry if I've poorly explained what I need!
It's SQL Server 2005.
Cheers,