A certain table in the MS SQL database has three fields: account, date and time of string type.
Now we need to add a sequence number column Seq for the group. When a new event occurs for an account within one hour, Seq+1; If a new event occurs after one hour, reset Seq to 1.
A1: Use JDBC to query the database, spell out the calculated column DT of date and time type, and sort it by account and DT.
A2: Create a new two-dimensional table and add a new calculated column Seq. When the account number of the current record is the same as the previous record and the time interval is within one hour, Seq+1; Otherwise, reset Seq to 1. [-1] represents the previous record of relative position.
Top comments (0)