Column headings in Union Query

C

CW

How do you edit the column headings in a Union Query?
I cannot get the normal Design View that would enable me to do this - I can
only get the SQL view.
Thanks
CW
 
O

Ofer Cohen

You can add another field to it
[FieldName] As NewFieldName

So if that is your union
SELECT TableName.*
FROM TableName
UNION
SELECT TableName2.*
FROM TableName2

Then adding another field with change of heading
SELECT TableName.*, [FieldName] As NewFieldName
FROM TableName
UNION
SELECT TableName.* , [FieldName] As NewFieldName
FROM TableName
 
C

CW

Thanks, Ofer, but it now produces an Enter Parameter Dialogue box (which I
do not want) and if I enter something in there just to get it to run, it
produces an extra column populated with the one value down all the rows.
If I give you exactly what I want to do, perhaps you would kindly show me
the correct syntax?

I have this as my original SQL:

SELECT [AgtName] FROM Agents
UNION SELECT [CorpName] FROM Corporates;

This runs OK and I get a column containing a mixture of Agent and Corporate
names. However, the heading is AgtName, which is not accurate. I want the
heading to be Booker.

I appreciate your help!
Thanks
CW

Ofer Cohen said:
You can add another field to it
[FieldName] As NewFieldName

So if that is your union
SELECT TableName.*
FROM TableName
UNION
SELECT TableName2.*
FROM TableName2

Then adding another field with change of heading
SELECT TableName.*, [FieldName] As NewFieldName
FROM TableName
UNION
SELECT TableName.* , [FieldName] As NewFieldName
FROM TableName

--
Good Luck
BS"D


CW said:
How do you edit the column headings in a Union Query?
I cannot get the normal Design View that would enable me to do this - I can
only get the SQL view.
Thanks
CW
 
O

Ofer Cohen

Try

SELECT [AgtName] As Booker FROM Agents
UNION SELECT [CorpName] As Booker FROM Corporates;


--
Good Luck
BS"D


CW said:
Thanks, Ofer, but it now produces an Enter Parameter Dialogue box (which I
do not want) and if I enter something in there just to get it to run, it
produces an extra column populated with the one value down all the rows.
If I give you exactly what I want to do, perhaps you would kindly show me
the correct syntax?

I have this as my original SQL:

SELECT [AgtName] FROM Agents
UNION SELECT [CorpName] FROM Corporates;

This runs OK and I get a column containing a mixture of Agent and Corporate
names. However, the heading is AgtName, which is not accurate. I want the
heading to be Booker.

I appreciate your help!
Thanks
CW

Ofer Cohen said:
You can add another field to it
[FieldName] As NewFieldName

So if that is your union
SELECT TableName.*
FROM TableName
UNION
SELECT TableName2.*
FROM TableName2

Then adding another field with change of heading
SELECT TableName.*, [FieldName] As NewFieldName
FROM TableName
UNION
SELECT TableName.* , [FieldName] As NewFieldName
FROM TableName

--
Good Luck
BS"D


CW said:
How do you edit the column headings in a Union Query?
I cannot get the normal Design View that would enable me to do this - I can
only get the SQL view.
Thanks
CW
 
C

CW

Perfect!
Thanks so much
CW

Ofer Cohen said:
Try

SELECT [AgtName] As Booker FROM Agents
UNION SELECT [CorpName] As Booker FROM Corporates;


--
Good Luck
BS"D


CW said:
Thanks, Ofer, but it now produces an Enter Parameter Dialogue box (which I
do not want) and if I enter something in there just to get it to run, it
produces an extra column populated with the one value down all the rows.
If I give you exactly what I want to do, perhaps you would kindly show me
the correct syntax?

I have this as my original SQL:

SELECT [AgtName] FROM Agents
UNION SELECT [CorpName] FROM Corporates;

This runs OK and I get a column containing a mixture of Agent and Corporate
names. However, the heading is AgtName, which is not accurate. I want the
heading to be Booker.

I appreciate your help!
Thanks
CW

Ofer Cohen said:
You can add another field to it
[FieldName] As NewFieldName

So if that is your union
SELECT TableName.*
FROM TableName
UNION
SELECT TableName2.*
FROM TableName2

Then adding another field with change of heading
SELECT TableName.*, [FieldName] As NewFieldName
FROM TableName
UNION
SELECT TableName.* , [FieldName] As NewFieldName
FROM TableName

--
Good Luck
BS"D


:

How do you edit the column headings in a Union Query?
I cannot get the normal Design View that would enable me to do this - I can
only get the SQL view.
Thanks
CW
 
Top