MySQL Forums
Forum List  »  Newbie

Newbie Help! Finding new data within a table comparing to previous records
Posted by: Adam Khan
Date: April 27, 2020 01:43AM

Hi Guys,

New to the MySQL world and did some lovely tutorials to build up my knowledge but am hitting a roadblock. I have a table which has data added daily in the same format. I am trying to build a query (or after some direction) to be able to search the table for NEW data based on the latest day's inputs and comparing that data with the previous 7 days data in the table.

The aim is to "Find/Search" new Data in the table that is added for that day when comparing it to the previous week based on Date, Customer and Score columns.

Here is the table structure and a few days worth of data. The table name is 'Data'.

As an example 'SBM' has been in the previous 7 days with the same rating as and is in today's data. The result is 'SBM' is not NEW and therefore wont be returned in the result. If a new Customer 'XYZ' appears in today's data, but 'XYZ' hasn't been in the previous 7 days then the returned query is 'XYZ' with the Date, Customer and Score.

Sounds easy but I've tried all sorts of things but cant work it out :(

HALP! Thanks!!

3 Columns as below.

Date Customer Score
2020-04-26 ARG 0.75
2020-04-26 AVG 0.75
2020-04-26 BRG 0.75
2020-04-26 CCP 0.80
2020-04-26 COH 0.75
2020-04-26 CSR 0.85
2020-04-26 GAP 0.75
2020-04-26 HVN 0.92
2020-04-26 MFG 0.75
2020-04-26 MNY 0.75
2020-04-26 OZL 0.80
2020-04-26 PMV 0.75
2020-04-26 SBM 0.80
2020-04-26 SGM 0.75
2020-04-26 TGR 0.85
2020-04-25 ARG 0.75
2020-04-25 AVG 0.75
2020-04-25 BRG 0.75
2020-04-25 CCP 0.80
2020-04-25 COH 0.75
2020-04-25 CSR 0.85
2020-04-25 HVN 0.85
2020-04-25 MFG 0.75
2020-04-25 MNY 0.75
2020-04-25 OZL 0.80
2020-04-25 PMV 0.75
2020-04-25 SBM 0.80
2020-04-25 SGM 0.75
2020-04-25 TGR 0.85
2020-04-24 ARG 0.75
2020-04-24 AVG 0.75
2020-04-24 BRG 0.75
2020-04-24 CCP 0.80
2020-04-24 COH 0.75
2020-04-24 CSR 0.85
2020-04-24 GAP 0.75
2020-04-24 HVN 0.85
2020-04-24 MFG 0.75
2020-04-24 MNY 0.75
2020-04-24 OZL 0.80
2020-04-24 PMV 0.75
2020-04-24 SBM 0.80
2020-04-24 SGM 0.75
2020-04-24 TGR 0.85
2020-04-23 ARG 0.75
2020-04-23 AVG 0.75
2020-04-23 BRG 0.75
2020-04-23 CCP 0.80
2020-04-23 COH 0.75
2020-04-23 CSR 0.85
2020-04-23 HVN 0.87
2020-04-23 MFG 0.75
2020-04-23 MNY 0.75
2020-04-23 OZL 0.80
2020-04-23 PMV 0.75
2020-04-23 SBM 0.80
2020-04-23 SGM 0.75
2020-04-23 TGR 0.85

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.