datediff()使用不同记录中的字段 [英] datediff() using fields from different records
问题描述
我正在尝试计算登录和注销日期时间字段的会话时间,但字段位于不同的记录和不同的列中。这可能是子查询吗?这里是非连续字段的示例,没有排序字段:
用户ID LogonhostDate LogoffhostDate
test1 228 9/4/2006 8:52 :下午38点
test1 229 9/4/2006 9:02:14 PM
test1 230 9/4/2006 9:06:59 PM
test1 231 9/4/2006 11:56:01 PM
test1 232 9/5/2006 12:01:56 AM
test1 233 9/5 / 2006 12:46:06
我不确定如何,或者甚至是必要的,将datetime字段放在同一条记录中。非常感谢任何帮助。
tdb
I am trying to calculate the session time for logon and logoff datetime fields, but the fields are in different records and different columns. Is this possible with a subquery? Here''s a sample of the non-sequential fields and no sequencing field:
User ID LogonhostDate LogoffhostDate
test1 228 9/4/2006 8:52:38 PM
test1 229 9/4/2006 9:02:14 PM
test1 230 9/4/2006 9:06:59 PM
test1 231 9/4/2006 11:56:01 PM
test1 232 9/5/2006 12:01:56 AM
test1 233 9/5/2006 12:46:06 AM
I am not sure how to, or even if it;s necessary, to get the datetime fields in the same record. Any help is much appreciated.
tdb
推荐答案
列未正确发布 - LogonhostDate字段与LogoffhostDate字段分开,以便每个记录都有一个或另一个,但从不两者都是这样,例如:ID 300是登录日期,301是注销日期。
the columns did not post correctly - the LogonhostDate field is separate from the LogoffhostDate field so that each record has one or the other, but never both so that for example: ID 300 is logon date and 301 is logoff date.
澄清 - 不同的字段不同的记录
clarification - different fields from different records
非常重要的问题 -
记录是否可以按混合顺序显示,或者228的注销总是在229?
另外,可以混合多个UserID吗?
因此,User1可以登录,用户2;然后User1或User2首先注销?
Very important question -
Can the records appear in mixed order or will the logoff for 228 ALWAYS be in 229?
Also, can multiple UserIDs be mixed up?
So, can User1 Log on,; followed by User2; then either User1 OR User2 Log off first?
这篇关于datediff()使用不同记录中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!