Menu

Advanced SQL Questions

MCQ
81.
Triggers ________ enabled or disabled
forum Discussion
MCQ
82.
Which prefixes are available to Oracle triggers?
forum Discussion
MCQ
83.
a _______ query that is nonrecursive and a __________ query.
forum Discussion
MCQ
84.
Ranking of queries is done by which of the following?
forum Discussion
MCQ
85.
In rank() function if one value is shared by two tuples then
forum Discussion
MCQ
86.
The __________ function that does not create gaps in the ordering.
forum Discussion
MCQ
87.
Inorder to give only 10 rank on the whole we should use
forum Discussion
MCQ
88.
).
forum Discussion
MCQ
89.
Inorder to simplify the null value confusion in the rank function we can specify
forum Discussion
NAT
90.
Consider a table **EmployeeLogs(emp_id INT, log_time TIMESTAMP, action VARCHAR(10))** where **action ∈ { 'LOGIN', 'LOGOUT' }**. Each employee may log in and out multiple times per day. Assume the table contains **10,00,000 rows**, and the following advanced SQL query is executed on a PostgreSQL-like system: ``` WITH session_pairs AS ( SELECT emp_id, log_time AS login_time, LEAD(log_time) OVER (PARTITION BY emp_id ORDER BY log_time) AS logout_time, LEAD(action) OVER (PARTITION BY emp_id ORDER BY log_time) AS next_action FROM EmployeeLogs ) SELECT COUNT(*) FROM session_pairs WHERE next_action = 'LOGOUT' AND logout_time IS NOT NULL AND logout_time > login_time; ``` Assume: - For every employee, **exactly 60%** of all rows are `'LOGIN'` actions. - Every `'LOGIN'` is eventually followed by a `'LOGOUT'` for the same employee. - No two consecutive actions for the same employee are `'LOGIN'`. - The distribution of rows across employees does not affect the ratio. Compute the **exact number of valid login–logout session pairs** returned by the query. Give the numerical answer.
forum Discussion
chevron_left BackPage 9 of 9