sriharsha.vemuri31
BAN USERhere a is productid b is price and c is time
select i.a,i.b from t5 i inner join
(select A,max(c) as c from t5 where c <=6 group by A ) j
on i.a = j.a and i.c=j.c
select A,(la - c) as total_time_spend from (select A,B,c,lag(c,1) over (partition by A order by A) as la from t4 ) where la is not null;
or
with exp as ( select A,max(c) as logout,min(c) as login from t4 group by A)
SELECT A,(logout - login) as total_spent_time from exp;
or
with exp as (
select a,max(c) as logout,min(c) as login from t4 group by a order by a
)
select a, (logout - login) as total_time_spend from exp;
Here A is name, B is event, C is event time
select cust_id,count(distinct branch_name) from deposit_branch group by cust_id having count(cust_id) =
(select count(distinct branch_id) from bank_branch)
Here distinct total count of branch id should match with the distinct count for the cust_id in depostit_branch
select * from emp a where 2 = (select count(distinct (b.salary)) from emp b where b.salary >= a.salary);
- sriharsha.vemuri31 August 24, 2019