Full Version: Union Query?
UtterAccess Discussion Forums > And More... > Microsoft SQL Server
Rmeier
I have to generate a report from my tables. I have 12 identical tables each old the same fields and type of data. But each is devided by only the primary key and the state in witch the data is for. I need to generate a query that pulls the same 6 fields from each of the tables and put them into a pivot table. I know this has to be done in sql but i know verry little about SQL. I can get the data to populate in diferent colmns on my query. But inorder for the pivot table to work correctly i need say all the users names under one colmn and the date submitted to be under the same colmn. Any help with this would be greatly appreciated.
truittb
Try this, just subsitute your field and table names and continue with all tables. Make sure the fields are in the same order in the SQL
CODE
Select UserName, DateSubmitted
From Table1
Union All
Select UserName, DateSubmitted
From Table2
Union All
Select UserName, DateSubmitted
From Table3
Union All
Select UserName, DateSubmitted
From Table4
toom21
Hello Pivot table users:

Make sure that there are no double quotes anywhere in your SQL statement. Use single quotations only.
Double quotes cause the "too few parameters expected" error message.

Also you need to use "ms query" to create pivot tables that use a union query as the data source.
Click on the Data tab--->From Other Sources--->From MS Query
For some reason the union queries do not show as an available external data source when you click on the 'insert' a Pivot table from the insert tab

Good luck


Michael
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.