0
I am trying to filter the dates when users connect to my system.
Have a however, first need to filter so there are no duplicate users.
I’m already doing it using the argument DISTINCT in my query, with the result that my query is returning, I want to search in the column DATE, to know every day that users have connected to my site.
I’m using the following command:
SELECT
*
FROM
wps_history
WHERE
inserted
BETWEEN "2016-11-01 00:00:00" AND "2016-11-30 23:59:59"
This command brings me all the results, but this is giving more than 40,000 lines, performing the filter DISTINCT the result and filtered to 500 lines, I am using the following command:
SELECT DISTINCT
user_id
FROM
wps_history
WHERE
inserted
BETWEEN
"2016-11-01 00:00:00" AND "2016-11-30 23:59:59"
Now I’m wondering how I can use the above command and bring up the dates on which each USER_ID
connected to my system.
Hello, Sorack, thank you very much. But I need all dates within the 30-day period. How can I adapt the code so that it returns all the dates you hear connection during the 30 days. Thanks for the (GROUP BY) tip. I’m crawling in the programming and I’m really enjoying it! Valeu
– Cícero Alves
@Cicero dispose. If the answer has solved your problem do not forget to mark to accept it. This way you can use it if someone has a similar question!
– Sorack
It helped me, but it didn’t completely solve my problem, because I need all the dates that each user_id connected to in the 30-day period. The GROUP BY tip was already a novelty for me, Thanks anyway!
– Cícero Alves
@Cíceroalves specify in the question which database you are using so I can supplement my answer
– Sorack
@Cicero tries to
BETWEEN GETDATE() -30 AND GETDATE()
. Sql-Server.– Marconi
@Sorack, I use Mysql. The column of the table "WPS_HISTORY" that records whenever a user connects is "DATA", I want to know which users "USER_ID", connected within 30 days. Thanks for your attention, if you can recommend me some books to read on the subject I will be grateful!
– Cícero Alves
@Cicero you want to show all dates in one column?
– Sorack
@Sorack the display can be either way
– Cícero Alves
@Marconi, thank you very much.
– Cícero Alves
@Cicero take a look at the answer I added at the end now
– Sorack
@Sorack thank you so much! Now it’s gone!
– Cícero Alves