Solved

Querry not working

Posted on 2014-04-19
2
159 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

688 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