Solved

union all between three table

Posted on 2013-01-10
2
416 Views
Last Modified: 2013-01-10
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d630590]
  where sent = 0


SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d732590]
  where sent = 0


SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d84444]
  where sent = 0


i want to union the three table and order by datein and timein
0
Comment
Question by:afifosh
2 Comments
 
LVL 21

Assisted Solution

by:Dale Burrell
Dale Burrell earned 250 total points
ID: 38765256
Add " union all " between each query and add " order by datein, timein" after the last query.
0
 
LVL 25

Accepted Solution

by:
jogos earned 250 total points
ID: 38765266
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d630590]
  where sent = 0

union all
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d732590]
  where sent = 0

union all
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d84444]
  where sent = 0
order by datein ,timein

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.‚Äč
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

920 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

16 Experts available now in Live!

Get 1:1 Help Now