So I have two huge linked tables, and I want to conduct a fairly complex query on them. I've managed to extract the data I need, but my process uses multiple sub queries and it's just too slow for my DB users.
Table 2 shows Facility ID, fluid type, fluid amount, and reporting date (as year and month, when I'd ultimately like year only).
Table 1 links Facility ID to Company ID, which I would ultimately like displayed rather than Facility ID (note that one company has many facilities). This table stores historical data as Company's often swap facilities, so only the most recent update date for each facility is required.
My output should be sorted by company, amount of fluid (with a different field for each fluid type), and year.
I'd love to hear any of your ideas on how to trim this down to a concise SQL statement!
Cheers,
-K
Table 2 shows Facility ID, fluid type, fluid amount, and reporting date (as year and month, when I'd ultimately like year only).
Table 1 links Facility ID to Company ID, which I would ultimately like displayed rather than Facility ID (note that one company has many facilities). This table stores historical data as Company's often swap facilities, so only the most recent update date for each facility is required.
My output should be sorted by company, amount of fluid (with a different field for each fluid type), and year.
I'd love to hear any of your ideas on how to trim this down to a concise SQL statement!
Cheers,
-K