-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnion Demo
24 lines (20 loc) · 892 Bytes
/
Union Demo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- In a Union, you are stacking rows together from two or more data sources. This can be particularly useful for situations where you get similar data from different source systems.
-- Run this code to understand how a UNION works.
-- Note that you may need to specify the schema before you table name. For example, my schema name is 'public', so I could have written 'public.immunizations' in the from portions of the UNION.
select 'Main EMR System' as Source
,imm.date
,imm.patient
,imm.encounter
,imm.code
,imm.description
from immunizations as imm
where date between '2019-01-01 00:00' and '2019-01-01 23:59'
UNION
select 'faxed EMR System' as Source
,imm.date
,imm.patient
,imm.encounter
,imm.code
,imm.description
from immunizations as imm
where date between '2018-12-31 00:00' and '2018-12-31 23:59'