Jump to content

Union results to columns


wizhippo

Recommended Posts

I have a query that is a number of unions that pull data from multiple tables.

SELECT 'CURRENT_YEAR' AS D, GLNAME, AMOUNT FROM ....

UNION

SELCT 'PREVIOUS_YEAR' AS D, GLNAME, AMOUNT FROM ...

UNION

SELECT 'PLAN' AS D, GLNAME,  AMOUNT FROM ....

I want to create 'AMOUNT' columns based on the 'D' columns

I can do this with a cross tab easy enough.  The issue is I need calculated columns based on D and the AMOUNT.

eg:

CURRENT_YEAR, PREVIOUS_YEAR, PLAN, CURRENT_YEAR-PLAN, CURRENT_YEAR-PREVIOUS_YEAR

 

Any ideas on how to do this?

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...