Тёмный
DataScience Atlas
DataScience Atlas
DataScience Atlas
Подписаться
Joins SQL For Interview
11:16
2 месяца назад
Robinhood SQL Interview Practice Question
4:17
2 месяца назад
Linkedin Practice SQL Interview Question
2:45
3 месяца назад
Episode 6: Bayes Theorem
3:05
6 месяцев назад
Episode 4: Random Variables
2:06
7 месяцев назад
Комментарии
@130_vanshika3
@130_vanshika3 6 часов назад
you need to check item too with my_cte as ( select *, lag(Timestamp) over (partition by Cust_ID order by timestamp) as next, lag(Searched_for) over (partition by Cust_ID order by timestamp) as itm from Sessions ) select * ,timestampdiff(minute,next,timestamp) from my_cte where (timestampdiff(minute,next,timestamp)>60 and Searched_for = itm) or next is null
@dhairyamahendru1159
@dhairyamahendru1159 9 дней назад
But how would you handle the records where the difference was less than 20 minutes but the hour was different like one at 8:50 and other one at 09:10?
@baun3024
@baun3024 26 дней назад
Recently fumbled this question in Meesho’s tech round. Finally got the solution for it. The solution is simple short and effective. Great video.
@Ujjwalmishra-t1w
@Ujjwalmishra-t1w Месяц назад
Nice mam
@RITIKSINGH-re5ne
@RITIKSINGH-re5ne Месяц назад
Kindly provide create and insert statements ?
@swapnilbankar9797
@swapnilbankar9797 Месяц назад
DENSE_RANK would be the most appropriate here. There wouldn't be a rank=2 if there are two orders with the same order value which is highest within a segment.
@tilu391
@tilu391 Месяц назад
with cte as( select seat_number,occupancy, sum(occupancy) over ( partition by substr(seat_number,1,1) rows between 3 preceding and current row)as rnk from cinema_tickets ) select seat_number from cte where rnk=0 and right(seat_number,1) not in(1,2,3); simple answer
@Ananya-ji3uc
@Ananya-ji3uc Месяц назад
Expedia SQL Interview Question: Find all possible unique routes in the month of January
@HARSHRAJ-wz2rp
@HARSHRAJ-wz2rp Месяц назад
with cte as( select DISTINCT(DATE(Order_timestamp)) as time_stamp1 FROM Orders where DAYOFWEEK(order_timestamp)=2 ),cte2 as( SELECT time_stamp1, COALESCE( LEAD(time_stamp1) OVER (ORDER BY time_stamp1), ADDDATE(time_stamp1, 7) ) AS time_stamp2 FROM cte ),cte3 as( SELECT cte2.time_stamp1, COUNT(*) AS total_orders, COUNT(CASE WHEN Orders.is_defective = TRUE THEN 1 ELSE NULL END) AS x1, COUNT(CASE WHEN Orders.is_completed = TRUE THEN 1 ELSE NULL END) AS x2 FROM cte2 JOIN Orders ON Orders.order_timestamp BETWEEN cte2.time_stamp1 AND cte2.time_stamp2 GROUP BY cte2.time_stamp1 ) select time_stamp1,(x1/total_orders) as deffective_rate,(x2/total_orders) as effective_rate FROM cte3; Good question
@MubarakAli-qs9qq
@MubarakAli-qs9qq Месяц назад
Very good question
@MubarakAli-qs9qq
@MubarakAli-qs9qq Месяц назад
Mujse kyu ni bana😢
@MubarakAli-qs9qq
@MubarakAli-qs9qq Месяц назад
I always prefer cte
@MubarakAli-qs9qq
@MubarakAli-qs9qq Месяц назад
Bhot hard
@RITIKSINGH-re5ne
@RITIKSINGH-re5ne Месяц назад
Great explanation!f Kindly increase Screen resolution from next vid onwards or zoom in a little bit
@MubarakAli-qs9qq
@MubarakAli-qs9qq Месяц назад
Nice question
@krishnenduchakraborty750
@krishnenduchakraborty750 Месяц назад
Thanks for sharing the Question & Solution. Your explanation is crystal clear. Keep it up. 😊👍
@abhinavkumar3356
@abhinavkumar3356 2 месяца назад
not to sound as creep but this is one of the most soothing voices I ever heard , please keep making such tutorial videos 🙂
@Ananya-ji3uc
@Ananya-ji3uc 2 месяца назад
Okay to clarify it's inner join, the distinction between cross join and inner is that in cross join we get cartesian product whereas in inner join it's primarily intersection of records. Besides when two tables have same columns - we can skip ON keyword and use USING keyword. The play of keywords doesn't decide the type of join we are implementing
@yashagarwal9900
@yashagarwal9900 2 месяца назад
Somehow the example you've taken has made the concept of Joins in SQL much more complicated (I would stick with categorical examples). I believe you've showed an example of Cross Join rather than INNER Join buy not using an ON clause.
@yashagarwal9900
@yashagarwal9900 2 месяца назад
Shouldn't the syntax be "INTERVAL '6' DAY " instead of "INTERVAL '6 days' "?
@Ananya-ji3uc
@Ananya-ji3uc 2 месяца назад
The syntax could vary I am using postgres sql
@siddhantgupta5301
@siddhantgupta5301 2 месяца назад
with cte as (select *, lag(occupancy,1) over(partition by substring(seat_number, 1, 1)) as prev_occ, lag(occupancy, 2) over(partition by substring(seat_number, 1, 1)) as prev_occ2, lag(occupancy, 3) over(partition by substring(seat_number, 1, 1)) as prev_occ3 from cinema_tickets) select concat(start_seat, '-', seat_number) as vacant from (select concat(substring(seat_number, 1, 1), substring(seat_number, 2, 2) - 3) as start_seat, seat_number from cte where occupancy = 0 and prev_occ = 0 and prev_occ2 = 0 and prev_occ3 = 0) a
@MusicalShorts-hn1px
@MusicalShorts-hn1px 2 месяца назад
Could you please share the table creation commands in description box to practice these questions
@Ananya-ji3uc
@Ananya-ji3uc 2 месяца назад
So this question is from practice site Datalemur : datalemur.com/questions/completed-trades Hope this helps:)
@vivekchaudhary5548
@vivekchaudhary5548 3 месяца назад
the last error was due to order of execution. You can't use alias name in where as "select" statement run after "where" clause. . . . . . . Btw your voice is ❤.
@pranavmalpani7355
@pranavmalpani7355 3 месяца назад
SELECT concat(seat,' to ',concat(left(seat,1),right(seat,1)+3)) as avaibable_seats FROM ( SELECT seat, ns1, ns2, ns3, ns4 FROM ( SELECT seat, occupancy AS ns1, LEAD(occupancy, 1) OVER(PARTITION BY LEFT(seat, 1) ORDER BY seat) AS ns2, LEAD(occupancy, 2) OVER(PARTITION BY LEFT(seat, 1) ORDER BY seat) AS ns3, LEAD(occupancy, 3) OVER(PARTITION BY LEFT(seat, 1) ORDER BY seat) AS ns4 FROM cinema_tickets ) AS s WHERE ns1 = 0 AND ns2 = 0 AND ns3 = 0 AND ns4 = 0 ) AS consecutive_empty_groups;
@wrestlingshorts
@wrestlingshorts 3 месяца назад
The question says unique users so doesn't that contradict the solutions ?, let me know if i am wrong
@Ananya-ji3uc
@Ananya-ji3uc 3 месяца назад
Hey @wrestlingshorts, could you explain contradict as in? So basically the question is if I am a user 'abc' and I have raised flags on videos say v1,v2 and v3, then query has to count those flags on each video.
@tensorthug6802
@tensorthug6802 3 месяца назад
Hey I'm an experienced machine learning engineer and I really appreciate what you're doing, keep going. All the best for your career.
@rajkumarpanigrahi2013
@rajkumarpanigrahi2013 3 месяца назад
Please solve some joins hard question
@Ananya-ji3uc
@Ananya-ji3uc 3 месяца назад
Sure will put up soon
@RITIKSINGH-re5ne
@RITIKSINGH-re5ne 4 месяца назад
Recommend at the right time preparing for a data analyst interview
@Ananya-ji3uc
@Ananya-ji3uc 3 месяца назад
All the Best!
@raashidnasim3803
@raashidnasim3803 4 месяца назад
Thank you for the video😊. Looking forward for more. A small request/suggestion the audio is barely audible.
@Ananya-ji3uc
@Ananya-ji3uc 4 месяца назад
Hey thanks for the input, that's work in progress
@chandravideo
@chandravideo 4 месяца назад
with cte as( SELECT *,cast(SUBSTRING(seat_number, 2, LEN(seat_number) - 1) as int) as sn, SUBSTRING(seat_number,1,1) as seat FROM cinema_tickets ),cte2 as( select *, lead(occupancy,1) over (partition by seat order by sn) as l1, lead(occupancy,2) over (partition by seat order by sn) as l2, lead(occupancy,3) over (partition by seat order by sn) as l3 from cte ) select seat_number,CONCAT(seat,sn+3) as succestive_next_seat from cte2 where occupancy+l1+l2+l3 = 0
@chandravideo
@chandravideo 4 месяца назад
A different approach
@Tech.S7
@Tech.S7 3 месяца назад
Yes it works for all dbs sql server N other dbs. For oracle in cte just change in first cte. Like below.... With cte as( Select t. *, TO_NUMBER (SUBSTR(seat_number, 2,LENGTH(seat_number)-1)) as sn, SUBSTR(t.seat_number, 1,1) as seat From cinema_tickets t And same you can continue from cte2
@blse2000
@blse2000 5 месяцев назад
If any one is looking out purely based on CTE's ;WITH CTE AS (SELECT * FROM cinema_tickets WHERE occupancy = 0 ), CTE2 AS (SELECT seat_number AS seat_number, occupancy AS occupancy, CAST(SUBSTRING(SEAT_NUMBER, 2, 2) AS INT) - (ROW_NUMBER() OVER (PARTITION BY SUBSTRING(SEAT_NUMBER, 1, 1) ORDER BY CAST(SUBSTRING(SEAT_NUMBER, 2, 2) AS INT) ) ) AS RN FROM CTE ), CTE3 AS (SELECT SUBSTRING(seat_number, 1, 1) AS SUB, RN AS RN, COUNT(RN) AS C FROM CTE2 GROUP BY SUBSTRING(seat_number, 1, 1), RN HAVING COUNT(RN) = 4 ), CTE4 AS (SELECT SUBSTRING(CTE2.SEAT_NUMBER, 1, 1) AS SEAT_ROW, CAST(SUBSTRING(CTE2.seat_number, 2, 2) AS int) AS SEAT_NUM FROM CTE3 INNER JOIN CTE2 ON SUBSTRING(CTE2.SEAT_NUMBER, 1, 1) = CTE3.SUB AND CTE2.RN = CTE3.RN WHERE CTE3.C = 4 ) SELECT SEAT_ROW, CONCAT(SEAT_ROW, CAST(MIN(SEAT_NUM) AS varchar(5))) AS MIN_SEAT, CONCAT(SEAT_ROW, CAST(MAX(SEAT_NUM) AS varchar(5))) AS MAX_SEAT FROM CTE4 GROUP BY SEAT_ROW
@bhanusri493
@bhanusri493 5 месяцев назад
The reason why she didn't get answer while using tab1 is you cannot use alias names along with where or having because according to order of execution Select statement will be executed after where/having is executed. So it do not recognize the new name that is assigned in select statement (which is not executed btw) . The approach of using tab2 is brilliant. Or you can directly use occupancy+s1+s2+s3 in where statement when using tab1. Just wanted to share.
@srinivasreddy8134
@srinivasreddy8134 5 месяцев назад
Can i get pdf of this questions
@dravikrish7323
@dravikrish7323 5 месяцев назад
How do we write if sales region max - each sales point of particular region? Example shop 1 revenue and total of all sales maximum of particular region?
@Ananya-ji3uc
@Ananya-ji3uc 5 месяцев назад
If the question is to display region, shop1, shop1 revenue, max revenue for the region Then we can create a cte to get maximum according to each region. Join this cte with the sales table on region to display the output.
@yashagarwal9900
@yashagarwal9900 5 месяцев назад
Thanks for posting DS content. Should one start from first video or are these random
@Ananya-ji3uc
@Ananya-ji3uc 5 месяцев назад
these are interview relevant questions, part of Data Science Trivia playlist, it can be read in any order
@Playz-K6
@Playz-K6 6 месяцев назад
Would you please tell me what do you refer to research on DS?
@Ananya-ji3uc
@Ananya-ji3uc 6 месяцев назад
Hey @danishmaxable9661, I usually refer varied sources especially data science blogs and content online nothing specific though.
@Playz-K6
@Playz-K6 6 месяцев назад
@@Ananya-ji3uc Thanks for the reply
@Rajkumar-xt7rj
@Rajkumar-xt7rj 6 месяцев назад
with cte as (select cust_id,txn_date,cumm_tax, rank() over(order by cumm_tax) as rnk from (SELECT cust_id,txn_date,sum(txn_amt) over(partition by cust_id order by txn_date) as cumm_tax FROM customer_txn ) x where cumm_tax >=2000 ) select * from cte order by cust_id limit 1
@jhonsen9842
@jhonsen9842 6 месяцев назад
You are just like me before solving this i did the same mistake
@hritickjain6318
@hritickjain6318 7 месяцев назад
Different approach: with tab1 as( Select *, sum(occupancy) over(partition by substring(seat_number, 1,1) order by cast(substring(seat_number,2,len(seat_number)) as int) rows between current row and 3 following) as sum_4_prec, lead(seat_number,3) over(partition by substring(seat_number, 1,1) order by cast(substring(seat_number,2,len(seat_number)) as int)) as end_seat from cinema_tickets ) Select seat_number, end_seat from tab1 where end_seat is not null and sum_4_prec = 0
@vishalmane3139
@vishalmane3139 Месяц назад
fck dude r u a human??
@priyankamalladi6262
@priyankamalladi6262 7 месяцев назад
Engaging stuff!
@jennygupta8868
@jennygupta8868 7 месяцев назад
Very innovative animation, great job👍 explained very well.
@emmimagnanaraj1085
@emmimagnanaraj1085 7 месяцев назад
Informative video!
@strawhatnd1285
@strawhatnd1285 7 месяцев назад
Great stuff
@prajaktamane9773
@prajaktamane9773 9 месяцев назад
Was this asked in initial hackerrank test?
@harshpalsingh763
@harshpalsingh763 9 месяцев назад
with cte as ( select *, sum(txn_amt) over(partition by cust_id order by txn_date ) as rolling_sum from customer_txn ) select cust_id,min(txn_date) as dates,min(rolling_sum) as rolling_sum from cte where rolling_sum>2000 group by cust_id this should give the same result
@jatinsingh7928
@jatinsingh7928 10 месяцев назад
Good
@jatinsingh7928
@jatinsingh7928 10 месяцев назад
Unclear problem statement
@dheemanjain8205
@dheemanjain8205 11 месяцев назад
with cte1 as (select *,sum(txn_amt) over(partition by cust_id order by cust_id,txn_date,txn_amt) as rs from customer_txn), cte2 as (select *,rank() over(partition by cust_id order by txn_date) as rn from cte1 where rs>=2000) select cte2.cust_id,cte2.txn_date from cte2 where rn=1;
@gauravdhakad796
@gauravdhakad796 Год назад
Can you share schema if you have?