?
Solved

Querry not working

Posted on 2014-04-19
2
Medium Priority
?
161 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…
Suggested Courses

770 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