问题描述
有谁知道用表1中的信息构建表2的方法吗?使用 Python 很容易接近,因为我可以使用按行检查".但是,后面有一个大数据集,所以如果我可以在SQL Server中用SQL语言进行数据转换,那就太好了.请注意,这不是真正的登录和注销数据结构/问题,我只想知道如何将表 2 中的数据转换为表 1.它与我现在拥有的数据具有相似的结构,但用于其他用途.
Does anyone know the way of building table 2 with information in table 1? It is easy to approach with Python because I can use ‘checking by row’. However, there is a big dataset at the back so if I could conduct the data transformation with SQL language in SQL Server it will be nice. Notice that this is not a real login and logout data structure/problem, and I just want to know how to transform data in table 2 into table 1. It has the similar structure with the data I have right now but for other use.
详情:当用户第一次登录我的系统时,我在表2中用‘LoginTime’记下时间.他可能会多次登录我的系统,但我只会记录他第一次登录的时间.当他第一次注销我的系统时,我会将表 1 中的Eventtime"记录为表 2 中的LogoutTime".如果同一用户没有注销,我会将 LogoutTime 保留为NULL".
Details: When the user first logs in to my system, I write down the time with ‘LoginTime’ in table 2. He might login to my system for several times but I will only record the very first time when he login. When he first logout of my system, I will record the ‘Eventtime’ from table 1 as ‘LogoutTime’ in table 2. If the same user doesn’t logout, I will keep the LogoutTime as ‘NULL’.
表一
表 2
推荐答案
您好,
解决方案初稿
请检查这是否满足您的需求
First draft of solution
Please check if this solve your needs
如果此解决方案适合您,那么我们知道我满足了您的需求,我们可以进行下一步,即讨论性能.为此,我们需要获取您的真实标签;e 结构和更多示例数据(来自您的 DDL+DML)
If this solution fits you then we know that I got your needs, and we can move to the next step which is discuss about performance. For this we will need to get your real tab;e structure ans some more sample data (DDL+DML from you)
这篇关于在 SQL Server 中使用 T-SQL 操作登录注销数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!