Solved

Querry not working

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

734 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