I have an issue in finding the changes between to tables.
I have a 2 discount files which i have uploaded to sql database using aws redshift.
I have to find the changes in both the tables. Which discount are changed for next month.
I have prepared the query but it brings all the columns from previous month as well.
My requirement is only changed data
I have created below query
(select * from imtest.aws_discount_new
minus
select * from imtest.aws_discount_prev)
UNION
(select * from imtest.aws_discount_prev
minus
select * from imtest.aws_discount_new);
But in this data from imtest.aws_discount_prev table which is not present in imtest.aws_discount_new are also included . which needs to be excluded
(select * from imtest.aws_discount_new
minus
select * from imtest.aws_discount_prev)
UNION
(select * from imtest.aws_discount_prev
minus
select * from imtest.aws_discount_new);
Expected : only new data from new file and data changed data prev file.
I think you only need the first part of your query:
select * from imtest.aws_discount_new
minus
select * from imtest.aws_discount_prev
This should get "new" records, which are not in "prev". That seems like a reasonable interpretation of what you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.