Quantcast
Channel: Answers for "how to get two columns depends on data in each row"
Browsing all 4 articles
Browse latest View live

Answer by ThomasRushton

I would suggest you look at the [PIVOT][1] statement, as this sort of thing is what it's there for, Here's an example of how it might look for you: First off, we set up a temporary table variable to...

View Article



Answer by Mrs_Fatherjack

Sorry I'm on SQL 2000 so don't have the joy of PIVOT, this does give you what was asked for, it's just a bit long winded. this works: SELECT accountid, SUM(CR) AS [Credit], SUM(DR) AS [Debit],...

View Article

Answer by ThomasRushton

I would suggest you look at the [PIVOT][1] statement, as this sort of thing is what it's there for, Here's an example of how it might look for you: First off, we set up a temporary table variable to...

View Article

Answer by Mrs_Fatherjack

Sorry I'm on SQL 2000 so don't have the joy of PIVOT, this does give you what was asked for, it's just a bit long winded. this works: SELECT accountid, SUM(CR) AS [Credit], SUM(DR) AS [Debit],...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images