Solved

Querry not working

Posted on 2014-04-19
2
148 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
2 Comments
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now