SQL Query - Non Duplicate Results

2

I want to return a search of the database without repeated data. The table is named Wps_history and contains the following columns:

id
user_id
adm_user_id
type
user
lancamento
data
valor
saldo
reason
ip
inserted   

I'm doing the search as follows:

select * 
from wps_history 
where inserted between "2016-11-01 00:00:00" AND "2016-11-30 23:59:59";

I'm getting duplicate user data, what I need to do is filter the result by user_id .

    
asked by anonymous 08.12.2016 / 16:36

1 answer

2

You need to use the DISTINCT clause with the column you want single data:

select DISTINCT(user_id) from wps_history where inserted between "2016-11-01 00:00:00" AND "2016-11-30 23:59:59"
    
08.12.2016 / 16:47