Find duplicates in two tables, report one of them, and keep unique entries

R

Ryan Fisher

Hi everyone,
I hope you might be able to help me out with a query for two tables.
I have two tables with daily weather data (temperature and
precipitation) from different weather stations across Canada. So the
fields are: weather station, date, temperature, and precipitation.
Each table contains the same fields but the data is produced from two
different quality control procedures (let's say QC1 and QC2). So there
may be exact duplicates (exact same temperature or precipitation value
on the same dates at the same weather station in QC1 and QC2), there
might be the same temperature value, but a different precipitation
value (or vice versa),or a date (or weather station) might be absent
in one table but present in another table. What I would like to do is
if there are exact duplicates in both QC1 and QC2 then I want to use
either one, if there are two records from QC1 and QC2 on the same date
for the same weather station but there are differences in the
temperature and precipitation values I want to use information from
QC1, and if a date or weather station is missing from one table or the
other I want the record where information is present. Here is what
each table looks like and what I want the output to look like:

Table QC1:
WeatherStationID Date Temperature
Precipitation
1 01/01/2003 12
0.5
1 02/01/2003 14
0
3 01/01/2003
5 0.2

Table QC2
WeatherStationID Date Temperature
Precipitation
1 01/01/2003 12
0.5
1 02/01/2003 14
0.2
2 01/01/2003 10
1.1

Resulting Table
WeatherStationID Date Temperature
Precipitation
1 01/01/2003 12
0.5
1 02/01/2003 14
0
2 01/01/2003 10
1.1
3 01/01/2003
5 0.2

I hope I've given enough information.
Thanks!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top