How to Convert Access Transform/Pivot Query for SQL Server

  • Thread starter Thread starter Charles Law
  • Start date Start date
C

Charles Law

I have posted this on a couple of Access and SQL Server newsgroups, but with
no answer yet. There seems to be very little activity on the ones I have
looked at, so I thought I would post here as well, since I have no doubt
that many people here also use Access/SQL Server. Anyway, enough of my
rambling and on with the problem/question.

I have two queries that I use in Access:

<qrySelect>
SELECT table2.column1, table2.column2, table2.column3, table1.column4 FROM
table1, table2 WHERE table1.column1 = table2.column1
</qrySelect>

<qryResult>
TRANSFORM First(qrySelect.column3) AS FirstOfCode
SELECT qrySelect.column1, qrySelect.column4, First(qrySelect.column3) AS
[Total Of Code] FROM qrySelect GROUP BY qrySelect.column1, qrySelect.column4
PIVOT qrySelect.column2
</qryResult>

I now wish to use them against a SQL Server database but I am unfamiliar
with the equivalent construct of Transform/Pivot in SQL Server. I read in
the MS documentation that I should use ROLLUP on the GROUP BY clause, but
try as I might I cannot make it work.

Can any one suggest how this might be done?

If there is a better newsgroup to post this question in I would be grateful
if someone could point me in the right direction.

TIA

Charles Law
 
Hi Charles,

I have checked which is the major SQL newsgroup and saw you had not placed
this message there.

It is not less smaller than the framework.aspnet newsgroup

Maybe you have a change there,

microsoft.public.sqlserver.programming

Cor
 
Thanks Cor. That looks like a good solution. I will try it. I had searched
Google but didn't turn this one up. I can't have been looking for the right
thing :-)

Cheers.

Charles
 
Back
Top