Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Querry not working

Posted on 2014-04-19
2
Medium Priority
?
166 Views
Last Modified: 2014-04-19
I am trying to create a union query. It will be a list of all the customers in the database. The list will be first LastName, FirstName and then FirstName, LastName.

Any idea why the below code isn't working?

SELECT UnionName.CustomerID
, UnionName.FullName
FROM ([Customer Info Table])
SELECT CustomerID, [LastName] & ", " & [FirstName] as [FullName], 1 as Seq
as UnionName
FROM [Customer Info Table]
UNION ALL
SELECT CustomerID, [FirstName] & " " & [LastName] as [FullName], 2 as SEQ
 as UnionName
ORDER BY UnionName.SEQ, UnionName.FullName

Open in new window

0
Comment
Question by:cansevin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
IrogSinta earned 2000 total points
ID: 40010653
Try this:
SELECT [CustomerID], [LastName] & ", " & [FirstName] AS FullName, 1 AS SEQ
FROM [Customer Info Table]
UNION ALL
SELECT [CustomerID], [FirstName] & " " & [LastName] AS FullName, 2 AS SEQ
ORDER BY [SEQ], [FullName] 

Open in new window

Ron
0
 

Author Closing Comment

by:cansevin
ID: 40010676
Thanks!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

604 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