There are a few different methods to determine the count of delay, active, and idle sessions in Teradata for the previous week, but one possible approach is as follows:
SELECT * FROM DBC.SessionInfo WHERE StartTime >= DATE '2022-01-09' AND StartTime < DATE '2022-01-16';
This query will return all sessions that started between January 9th and January 15th, which represents the previous week.
SELECT COUNT(*) FROM DBC.SessionInfo WHERE StartTime >= DATE '2022-01-09' AND StartTime < DATE '2022-01-16';
This will give you the total count of active sessions during the previous week.
SELECT COUNT(*) FROM DBC.SessionInfo WHERE StartTime >= DATE '2022-01-09' AND StartTime < DATE '2022-01-16' AND (CURRENT_TIMESTAMP - LastResponseTimeStamp) HOUR > 1;
This will give you the total count of idle sessions during the previous week.
SELECT COUNT(*) FROM DBC.SessionInfo WHERE StartTime >= DATE '2022-01-09' AND StartTime < DATE '2022-01-16' AND (CURRENT_TIMESTAMP - StartTime) HOUR > 1;
This will give you the total count of delayed sessions during the previous week.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-12 00:08:02 +0000
Seen: 11 times
Last updated: Jun 12 '23
How can Teradata check a condition based on both ID and Date in a case?
In PySpark, how does the lead function work when the value of a column changes?
How can SQL output be structured in a column-based XML format instead of row-based?
How can pgcrypto be used to secure data on Postgres?