Click here to Skip to main content
15,881,730 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,

relatively new to SQL. Bear with me, please.

I've written a script that inserts two sets of data into temp tablesand subsequently selects data, via joins, from the two of them to relate data in the following columns:
Set.1
Business Volume | Number of Properties | Office | Avg. Days on Market
MONEY VALUE 1___INT 1______________NAME1________INT 1
MONEY VALUE 2___INT 2______________NAME2________INT 2
...

Here's the thing, I'm looking to have this data display on a yearly basis such that the columns would be:
Set.2
Year | Business Volume | Number of Properties | Office | Avg. Days on Market
2008_ MONEY VALUE 1.0_______INT 1.0________NAME1.0_____INT 1.0
2009_ MONEY VALUE 1.1_______INT 1.1________NAME1.1_____INT 1.1
...
2008_ MONEY VALUE 2.0_______INT 2.0________NAME2.0_____INT 2.0
2009_ MONEY VALUE 2.1_______INT 2.1________NAME2.1_____INT 2.1
...

As of right now Set.1 is an aggregate of what I want, not broken down by year. Set.2 is what I'm after - a year-by-year breakdown of what Set.1 is.

I've been told I can use a Pivot, or possibly Case statements, but pivot examples don't seem to use script with temp tables. Any suggestions? I could include the actual script or other information, if needed.

Thanks.
Posted
Updated 24-Jul-12 7:28am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900