Solved

union all between three table

Posted on 2013-01-10
2
420 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS - Date Report Options 2 29
backup and restore 21 30
SQL trigger 5 23
MS SQL SERVER and ADODB.commands 8 23
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.‚Äč
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

828 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