SQL data discharge, remove duplicate data

xiaoxiao2021-03-06  23

The biggest error: When the data is discounted, the first thought is Distinct, although this is used, but it is not applicable under most occasions, because it will be further processed after it is usually discharged, for example, after the number is discharged, according to the date Statistics, etc.

Unable to discharge, GROUP BY ... HAVING ... Although you can use Group by Userid Having Count (*) = 1 or> 1, but only you can find repetitive or non-repetitive records, it seems that Distinct is achieved ( I didn't do it, a ah, stupid).

This can: use Select * from table t where not exists (SUBMIT_TIME) (Submit_time) (Submit_time) (Submit_time) Cheng), but also achieved an effect, the first time the user ID is calculated, which is still useful in many cases (such as what is wrong).

It is worth noting: When it is discounted with the above method, if there are other conditions after the SELECT * .... WHERE ..., these conditions must also be written into the SELECT 1 from .... where.. .. ie, ie, the external conditions must be the same (I just didn't pay attention, find the result than a few Distinct, depressed, long time: ()

转载请注明原文地址:https://www.9cbs.com/read-40447.html

New Post(0)