每天的唯一行数

发布于 2024-11-16 08:51:35 字数 353 浏览 3 评论 0原文

我需要获取一天内登录我的网站的用户电子邮件地址列表。

该列表可能包含重复的电子邮件地址,但每天不得超过一个。

我需要获取一周的数据。

我有一个表,其中包含每次成功登录的记录,如下所示。

[ID], [LOGIN_EMAIL], [LOGIN_TIME]

以下查询获取本周的整个数据集,但我需要每天将其过滤到一个电子邮件地址并获取本周的整个列表?

SELECT LOGIN_EMAIL 
FROM USER_LOGINS 
WHERE LOGIN_TIME IS BETWEEN @STARTDATE AND @ENDDATE

I need to get a list of users email addresses that logged into my website over the course of a day.

The list may contain duplicate email addresses but not more than one per day.

I need to obtain this data for a week.

I have a table that contains records for each successful login as follows..

[ID], [LOGIN_EMAIL], [LOGIN_TIME]

The following query gets me the whole data set for the week but I need to filter it to one email address per day and get the entire list for the week?

SELECT LOGIN_EMAIL 
FROM USER_LOGINS 
WHERE LOGIN_TIME IS BETWEEN @STARTDATE AND @ENDDATE

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

酒绊 2024-11-23 08:51:35
SELECT   LOGIN_EMAIL,
         DATEADD(DAY, DATEDIFF(DAY, 0, LOGIN_TIME), 0) AS LOGIN_DATE
FROM     USER_LOGINS 
WHERE    LOGIN_TIME BETWEEN @STARTDATE AND @ENDDATE
GROUP BY LOGIN_EMAIL, 
         DATEADD(DAY, DATEDIFF(DAY, 0, LOGIN_TIME), 0)
SELECT   LOGIN_EMAIL,
         DATEADD(DAY, DATEDIFF(DAY, 0, LOGIN_TIME), 0) AS LOGIN_DATE
FROM     USER_LOGINS 
WHERE    LOGIN_TIME BETWEEN @STARTDATE AND @ENDDATE
GROUP BY LOGIN_EMAIL, 
         DATEADD(DAY, DATEDIFF(DAY, 0, LOGIN_TIME), 0)
明明#如月 2024-11-23 08:51:35

使用按天([LOGIN_TIME])、[LOGIN_EMAIL]分组

Use group by Day([LOGIN_TIME]), [LOGIN_EMAIL]

雨夜星沙 2024-11-23 08:51:35
SELECT DISTINCT LOGIN_EMAIL,LOGIN_TIME FROM USER_LOGINS WHERE LOGIN_TIME IS BETWEEN @STARTDATE AND @ENDDATE

您可能需要将 LOGIN_TIME 更改为日格式

SELECT DISTINCT LOGIN_EMAIL,LOGIN_TIME FROM USER_LOGINS WHERE LOGIN_TIME IS BETWEEN @STARTDATE AND @ENDDATE

you may need to chnge LOGIN_TIME to Day format

忱杏 2024-11-23 08:51:35
   select DISTINCT CONVERT(VARCHAR(10), LOGIN_TIME, 102) as LogDate, login_email 
   from user_logins WHERE ...
   select DISTINCT CONVERT(VARCHAR(10), LOGIN_TIME, 102) as LogDate, login_email 
   from user_logins WHERE ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文