SQL UNION Example

A couple SQL UNION query examples.

SELECT
[%$##@_Alias].ServiceProvider,
Count([%$##@_Alias].ServiceProvider) AS SPCount
FROM
[SELECT
tblSurveyResults.[Service Providers 1] AS ServiceProvider
FROM tblSurveyResults
UNION ALL
SELECT
tblSurveyResults.[Service Providers 2] AS ServiceProvider
FROM tblSurveyResults
UNION ALL
SELECT tblSurveyResults.[Service Providers 3] AS ServiceProvider
FROM tblSurveyResults ]. AS [%$##@_Alias]
GROUP BY [%$##@_Alias].ServiceProvider;

This one from the Microsoft Access help file:

SELECT [CompanyName], [City] FROM [Suppliers]
UNION
SELECT [CompanyName], [City] FROM [Customers] ORDER BY [City];

Related Scribbles:
  • SQL Syntax, Query Examples and Notes


  • ID: 189
    Author:
    leonard
    Date Updated:
    2004-09-02 12:39:18
    Date Created:
    2002-09-22 17:34:26

    Edit

    Comments?
     >> Leonard Chan's Homepage  >> Scribble Web  >> SQL UNION Example
    leonard.lotus-land.ca is hosted by Perceptus Solutions Inc.