Solved

TRANSFORM query for MS Access using .NET

Posted on 2010-11-25
3
271 Views
Last Modified: 2012-05-10
Below I can't do the first query but can do the second query. The queries are the same, creating a make table query on the result of another query, but the second query has a TRANSFORM and PIVOT part while the first doesn't. So, I don't know much abou that type of query... except that it didn't work... what's the reason for that? (I mean, both simply produce a table as a result... so I don't know why I can't call that table 'Temp' and then SELECT INTO a new table called RevenueByCountryAct.

CAN'T do this query

strSQL = "SELECT Temp.* INTO RevenueByCountryAct FROM"
strSQL = strSQL + " (TRANSFORM Sum([Table1].BillAmount) AS SumOfBillAmount"
strSQL = strSQL + " SELECT [Table1].FILESOURCE, [Table1].TYPE, [Table1].[Product Code], [Table1].Service, [Table1].Service2, [Table1].Service3, [Table1].COUNTRY"
strSQL = strSQL + " FROM [Table1]"
strSQL = strSQL + " GROUP BY [Table1].FILESOURCE, [Table1].TYPE, [Table1].[Product Code], [Table1].Service, [Table1].Service2, [Table1].Service3, [Table1].COUNTRY"
strSQL = strSQL + " PIVOT [Table1].[Billing Period]) AS Temp"

Open in new window


CAN do this query

strSQL = "SELECT Temp.* INTO RevenueByCountryAct FROM"
strSQL = strSQL + " (SELECT [Table1].FILESOURCE, [Table1].TYPE, [Table1].[Product Code], [Table1].Service, [Table1].Service2, [Table1].Service3, [Table1].COUNTRY"
strSQL = strSQL + " FROM [Table1]"
strSQL = strSQL + " GROUP BY [Table1].FILESOURCE, [Table1].TYPE, [Table1].[Product Code], [Table1].Service, [Table1].Service2, [Table1].Service3, [Table1].COUNTRY"
strSQL = strSQL + ") AS Temp"

Open in new window

0
Comment
Question by:AidenA
3 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34213594
That is not possible with Access syntax.
What you can do is store the TRANSFORM query by name, then follow up with another
select * into newtable from QueryWithTransform
0
 
LVL 44

Expert Comment

by:GRayL
ID: 34214861
Pres Alt+F11, Microsoft Visual Basic Help, Microsoft Jet Reference, Data Manipulation Language, SQL Subqueries - this is of interest:

Some subqueries are allowed in crosstab queries — specifically, as predicates (those in the WHERE clause). Subqueries as output (those in the SELECT list) are not allowed in crosstab queries.



0
 

Author Comment

by:AidenA
ID: 34218119
thanks cyberkiwi, followed your suggestion and it worked fine. Not the way I'd prefer to do it, but it shouldn't be a problem at the same time so I'll go ahead with that.

Thanks, Aiden
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question