- Видео 31
- Просмотров 60 224
Coding Lake
Индия
Добавлен 11 авг 2023
Hi Myself Shubham Saha MCA Graduate.
In This Channel I will Upload All Computer Related Topic's Like Computer Basic To Advance Concept.
If You Like My Content Please Like Share And Subscribe To My Channel.
Thank You For Visiting My Channel.
In This Channel I will Upload All Computer Related Topic's Like Computer Basic To Advance Concept.
If You Like My Content Please Like Share And Subscribe To My Channel.
Thank You For Visiting My Channel.
SQL Interview Question | 25 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
If you like this video please
like share , subscribe and comment down below..
if you have any suggestion or doubt this video.
script:
create table puzzle(id int,rules varchar(10),value int)
insert into puzzle values(1,'1+3',10)
insert into puzzle values(2,'2*5',12)
insert into puzzle values(3,'3-1',14)
insert into puzzle values(4,'4/1',15)
insert into puzzle values(5,'5+4',18)
like share , subscribe and comment down below..
if you have any suggestion or doubt this video.
script:
create table puzzle(id int,rules varchar(10),value int)
insert into puzzle values(1,'1+3',10)
insert into puzzle values(2,'2*5',12)
insert into puzzle values(3,'3-1',14)
insert into puzzle values(4,'4/1',15)
insert into puzzle values(5,'5+4',18)
Просмотров: 211
Видео
SQL Interview Question | 24 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,3 тыс.4 часа назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt in this video. script: create table company_info(company_name varchar(10),year_cal int,revenue int) insert into company_info values('x',2020,100) insert into company_info values('x',2021,90) insert into company_info values('x',2022,120) insert into company_info values('y',2020,100) ...
SQL Interview Question | 23 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,6 тыс.9 часов назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. script: create table emp(id int,emp_name varchar(20),gender varchar(10),dept varchar(20),salary int) insert into emp values (1, 'Tildie', 'Female', 'Support', 1676); insert into emp values (2, 'Averil', 'Female', 'Engineering', 1572); insert into emp values (3, 'Matthiew...
SQL Interview Question | 22 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,9 тыс.14 часов назад
If you like this video please like share , subscribe and comment down below, if you have any suggestion or doubt in this video. script: create table cricket_match (match_id int,team1 Varchar(20),team2 Varchar(20),result Varchar(20)); INSERT INTO cricket_match values(1,'ENG','NZ','NZ'); INSERT INTO cricket_match values(2,'PAK','NED','PAK'); INSERT INTO cricket_match values(3,'AFG','BAN','BAN'); ...
SQL Interview Question | 21 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,2 тыс.19 часов назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. script: create table transactions ( id int primary key, country varchar(15), state varchar(15), amount int, trans_date date ) insert into transactions values(1,'US','approved',1000,'2023-12-18') insert into transactions values(2,'US','declined',2000,'2023-12-19') insert ...
SQL Interview Question | 20 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,4 тыс.День назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. SQL script: CREATE TABLE emp( emp_id int , emp_name varchar(15) NULL, salary int NULL, manager_id int NULL, dept varchar(10) NULL ) INSERT into emp VALUES (1, 'navin', 1300, 2, 'sales') INSERT into emp VALUES (2, 'ankit', 1200, 3, 'sales') INSERT into emp VALUES (3, 'kav...
SQL Interview Question | IBM | 19 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,8 тыс.День назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. scripts: create table ticket(ticket_id int,issue_date date,resolve_date date) insert into ticket values(1,'2024-12-18','2025-01-7') insert into ticket values(2,'2024-12-20','2025-01-10') insert into ticket values(3,'2024-12-22','2025-01-11') insert into ticket values(4,'...
SQL Interview Question | TCS | 18 #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,6 тыс.14 дней назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. create table call_start(ph_no varchar(10),start_time datetime); insert into call_start values ('contact_1','2024-05-01 10:20:00'), ('contact_1','2024-05-01 16:25:00'), ('contact_2','2024-05-01 12:30:00'), ('contact_3','2024-05-02 10:00:00'), ('contact_3','2024-05-02 12:3...
SQL Interview Question | 17 #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,3 тыс.14 дней назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. scripts: create table emp(emp_id int identity,emp_name varchar(15),salary int,manager_id int) insert into emp values('navin',1300,2) insert into emp values('ankit',1200,3) insert into emp values('kavya',1250,4) insert into emp values('ranjit',1600,5) insert into emp valu...
Joins In SQL Interview Question | 16 | #dataanalyst | #powerbi | #sql | #plsql | #dataengineer
Просмотров 1,4 тыс.14 дней назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. scripts: create table t1(id int) create table t2(id int) insert into t1 values(1) insert into t1 values(1) insert into t1 values(0) insert into t1 values(0) insert into t1 values(null) insert into t1 values(null) insert into t2 values(1) insert into t2 values(1) insert i...
SQL Interview Question | EY | 15 | #dataengineer | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 2,4 тыс.14 дней назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. scripts: CREATE TABLE product( product varchar(15) NULL, amount int NULL, country varchar(10) NULL ) INSERT into product VALUES ('banana', 1000, 'usa') INSERT into product VALUES ('carrots', 1500, 'usa') INSERT into product VALUES ('beans', 1600, 'usa') INSERT into produ...
SQL Interview Question | 14 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 2,9 тыс.21 день назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. scripts: create table office ( emp_id int , emp_status varchar(10) , time_id datetime); insert into office values ('1', 'in', '2023-12-22 09:00:00'); insert into office values ('1', 'out', '2023-12-22 09:15:00'); insert into office values ('2', 'in', '2023-12-22 09:00:00...
SQL Interview Question | 13 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 2 тыс.21 день назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. Scripts: CREATE TABLE emp( emp_id int NULL, emp_name varchar(20) NULL, salary int NULL, gender char(1) NULL ) insert into emp VALUES (1, 'Rajesh', 1000, 'M') insert into emp VALUES (1, 'Rajesh', 1000, 'M') insert into emp VALUES (2, 'Yogesh', 1500, 'M') insert into emp V...
SQL Interview Question | 12 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 7 тыс.21 день назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. Scripts: CREATE TABLE office( emp_id int, experience [varchar](20) , [salary] [int] ) INSERT INTO office VALUES (1, 'Junior', 10000) INSERT INTO office VALUES (2, 'Junior', 15000) INSERT INTO office VALUES (3, 'Junior', 40000) INSERT INTO office VALUES (4, 'Senior', 1600...
SQL Interview Question | 11 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 2 тыс.28 дней назад
If you like this video please like share , subscribe and comment down below.. if you have any suggestion or doubt this video. script CREATE TABLE hall_ticket( id int, seat_id int, ) INSERT INTO hall_ticket VALUES (1, 1) INSERT INTO hall_ticket VALUES (2, 0) INSERT INTO hall_ticket VALUES (3, 1) INSERT INTO hall_ticket VALUES (4, 1) INSERT INTO hall_ticket VALUES (5, 1) INSERT INTO hall_ticket V...
RANK, DENSE_RANK, ROW_NUMBER | 10 |Window Function In SQL | #dataanalyst | #dataengineer | #powerbi
Просмотров 476Месяц назад
RANK, DENSE_RANK, ROW_NUMBER | 10 |Window Function In SQL | #dataanalyst | #dataengineer | #powerbi
Custom Sort In SQL | 09 | Most Important Interview Question | #powerbi #dataengineering #dataanalyst
Просмотров 1,7 тыс.Месяц назад
Custom Sort In SQL | 09 | Most Important Interview Question | #powerbi #dataengineering #dataanalyst
TOP 5 SQL Interview Question Part 2 | 08 | #powerbi #dataengineering #dataanalyst | #dataengineer
Просмотров 1,1 тыс.Месяц назад
TOP 5 SQL Interview Question Part 2 | 08 | #powerbi #dataengineering #dataanalyst | #dataengineer
SQL Interview Question , Max and Min Function | 07 | #powerbi | #dataengineer #sql | #dataanalyst
Просмотров 2,2 тыс.Месяц назад
SQL Interview Question , Max and Min Function | 07 | #powerbi | #dataengineer #sql | #dataanalyst
TOP 5 SQL Interview Question | #powerbi #dataengineering #dataanalyst
Просмотров 1,5 тыс.Месяц назад
TOP 5 SQL Interview Question | #powerbi #dataengineering #dataanalyst
SQL Interview Question | 05 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,4 тыс.Месяц назад
SQL Interview Question | 05 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
SQL Interview Question | 04 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 7 тыс.Месяц назад
SQL Interview Question | 04 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
SQL Interview Question | 03 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 10 тыс.Месяц назад
SQL Interview Question | 03 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Convert Unpivot table to pivot table In SQL | 02 | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 3,3 тыс.2 месяца назад
Convert Unpivot table to pivot table In SQL | 02 | #dataanalyst | #powerbi | #sql #dataengineer
SQL Interview Question | 01 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
Просмотров 1,7 тыс.2 месяца назад
SQL Interview Question | 01 | #dataengineering | #dataanalyst | #powerbi | #sql #dataengineer
SQL Interview Question | Amazon | Series 06
Просмотров 3533 месяца назад
SQL Interview Question | Amazon | Series 06
SQL Interview Question | BookMyShow | Series 05
Просмотров 2654 месяца назад
SQL Interview Question | BookMyShow | Series 05
SQL Interview Question | Deloitte | Series 04
Просмотров 3404 месяца назад
SQL Interview Question | Deloitte | Series 04
SQL Interview Question | TCS | Series 03
Просмотров 3264 месяца назад
SQL Interview Question | TCS | Series 03
SQL Interview Question | PWC | Series 02
Просмотров 3194 месяца назад
SQL Interview Question | PWC | Series 02
Bro pls mention this type of scenario based questions for beginners or for experience it better to learn more
Thanks ❤
Very good problem. Excellent explanation. Thanks 😊
Excellent example.
with cte_1 AS (SELECT *,SUM(salary) OVER(PARTITION BY experience ORDER BY emp_id ) AS cum_sum FROM office), cte_2 AS ( SELECT ('60000'- SUM(salary)) ramount FROM cte_1 WHERE experience='Senior' AND cum_sum <='60000') SELECT * FROM cte_1 WHERE experience='Junior' AND cum_sum <=(SELECT * FROM cte_2) UNION SELECT * FROM cte_1 WHERE experience='Senior' AND cum_sum <='60000' ;
with cte AS (SELECT *,DATE_FORMAT(trans_date,'%y-%m') AS months ,case when state='approved' then 1 ELSE 0 end AS approved_tx_count, case when state='approved' then amount ELSE 0 end AS approved_tx_amount FROM transactions) SELECT months,country,COUNT(*) AS tx_count,SUM(amount) AS tx_amount, SUM(approved_tx_count), max(approved_tx_amount) FROM cte GROUP BY months,country ;
SELECT team,COUNT(*) AS NOofmatch,SUM(case when team=result then 1 ELSE 0 END) AS won, SUM(case when team !=result then 1 ELSE 0 END) AS loss from( SELECT team1 AS team,result FROM cricket_match UNION ALL SELECT team2 as team,result FROM cricket_match) AS k GROUP BY team ORDER BY team ;
with cte AS ( SELECT * , LAG(revenue,1,0) OVER(PARTITION BY company_name ORDER BY year_cal) AS pre_revenue, COUNT(company_name) OVER (PARTITION BY company_name ) AS COUNT_1 FROM company_info ORDER BY company_name,year_cal), cte2 AS ( SELECT *,COUNT(company_name) OVER (PARTITION BY company_name) AS COUNT_2 FROM cte WHERE revenue >= pre_revenue) SELECT * FROM cte2 WHERE COUNT_1 =COUNT_2 ;
Bhai bitwise ke interview sql questions pe video banale
thumbnail output is different than actual output (😇) select to_char(trans_date , 'yyyy-mm'),country, count(state),sum(case when state = 'approved' then 1 else 0 end),sum(amount) from transactions10 group by to_char(trans_date , 'yyyy-mm'),country
my solution with cte as ( select * , case when revenue - (lag(revenue , 1 , 0) over (partition by company_name order by year_cal)) >=0 then 0 else 1 end as diffrence from company_info) select company_name from cte group by company_name having sum(diffrence) = 0
with main as (select *, lag(revenue,1,0) over(partition by company_name order by year_cal) as prev, lead(revenue,1,0) over(partition by company_name order by year_cal) as next from company_info), result as (select *, case when next>revenue and prev<revenue then 1 when next= revenue or prev=revenue then 1 else 0 end as flag from main ) select company_name from result where flag=1 group by company_name;
with temp as (select c.*, case when lead(revenue,1,revenue) over(partition by company_name order by year_cal) >= revenue then 1 else 0 end as flag from company_info c) select * from company_info where company_name not in (select company_name from temp where flag = 0)
Superb explanation 👌 👏 👍
with CTE as (select *, revenue - (lag(revenue) over(partition by company_name order by year_cal)) as yr_rn from company_info) select company_name, year_cal, revenue from CTE where company_name in (select company_name from CTE group by company_name having min(yr_rn) >=0)
select team_name , count(1) as no_of_matches_played,sum(win_flag) as no_of_matches_won,(count(1) - sum(win_flag)) as no_of_matches_lost from ( select team1 as team_name,case when team1 = result then 1 else 0 end as win_flag from cricket_match union all select team2 as team_name, case when team2 = result then 1 else 0 end as win_flag from cricket_match )a group by team_name;
with cte as ( select * ,row_number() over(partition by dept order by salary ASC) as min_rn ,row_number() over(partition by dept order by salary DESC) as max_rn from emp ) select dept ,max(case when min_rn = 1 then salary end) as min_salary ,min(case when max_rn = 1 then salary end ) as max_salary from cte group by dept
A little different query than yours. I didn't used Order By inside the CTE. with cte as( select e.*, m.name as manager_name, count(m.id) over(partition by m.id)as cnt from employee e inner join employee m on e.managerId = m.id) select manager_name,count(*) as no_of_employees_managed from cte where cnt >4 group by manager_name;
Nice one
superb explanation.........
Thanks! 🙂
We can also check the last status of employee whether it's IN or OUT and based on that we can find out employees who are inside the office. WITH CTE AS( SELECT *, LAST_VALUE(EMP_STATUS) OVER(PARTITION BY EMP_ID ORDER BY TIME_ID ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS FLAG FROM OFFICE ) SELECT DISTINCT EMP_ID FROM CTE WHERE FLAG='IN';
Nice one
While querying on top of cte sum(flag) alone would work as we have only 1 and 0 as flag values
select emp_id,max(case when salary_component_type ="salary" then val end )as salary, max(case when salary_component_type="bonus" then val end) as bonus, max(case when salary_component_type ="hike_percent" then val end) as hike_percent from emp group by emp_id ;
Interesting query.
Thanks, I hope you learned something new!
Very nice 🙂 plz continue provide more videos that are generally asked in interviews
Sure, I'll try to make more interview-focused videos.
if possible can post pdf of all the videos you have posted
Sure, I will try to upload PDFs for future videos.
just keep going bro
Thanks, will do!
Great explaining..Your step-by-step breakdown made it easy to understand the logic and purpose behind each part..
thanks.
Directly why not dense_rank() ?
Just a small change, used IIF insted of Case when WITH cte AS ( SELECT *,FORMAT(trans_date, 'yyy-MM') as month FROM transactions) SELECT month, country, count(*) AS trans_count, SUM(amount) AS trans_total_Amount, SUM(IIF(state = 'Approved', 1, 0)) AS approved_count, SUM(IIF(state = 'Approved', amount, 0)) AS approved_total_amount FROM cte GROUP BY month, country
Nice 👍
U made complicated😢
Try once then see it's easy.
This is literally the way one will write it. What's complicated in it?
Simply you can filter the date by state = 'approved'
But how do you sum multiple approved transactions and transaction counts.
Nicely explained
Thanks.
Well Explained 👍
Thank you 🙂
another approach with cte as( select FORMAT(trans_date,'yyyy-MM') as month,country, count(*) cnt, sum(amount) trans_total_amount from transactions_thus group by FORMAT(trans_date,'yyyy-MM') , country ), cte2 as( select FORMAT(trans_date,'yyyy-MM') as month2, count(*) approved, amount from transactions_thus where state='approved' group by amount, FORMAT(trans_date,'yyyy-MM') ) select c1.*, approved, amount from cte c1 inner join cte2 c2 on c1.month = c2.month2
Nice one 👍
Very important points 👍 super
Thanks 👍
Firstly thanks, got to learn this kind of join! But, if any ticket is opened on friday and closed on monday, actual business days taken is 1 day. As per your logic does it give 1 or 3?
In that scenario week count 1 and day count will be 2. You can also datediff function. So the concept would be more clear.
Wow great 😮
WITH cte AS ( SELECT *, MIN(population) OVER(PARTITION BY state) AS min_pop, MAX(population) OVER(PARTITION BY state) AS max_pop FROM city_info ) SELECT state, MIN(CASE WHEN population = min_pop THEN city END) AS minimum_popluation, MAX(CASE WHEN population = max_pop THEN city END) AS maximum_population FROM cte GROUP BY state;
Nice one 👍
Awesome explanation 😃
thanks.
Keep up the good work!
thanks.
solve problem on window functions
with cte as (select max(resolve_date) as MAX_DATE from ticket ), cte2 as( select min(issue_date)STRT_DATE from ticket union all select DATEADD(dd,1,STRT_DATE) from cte2,cte where STRT_DATE<=MAX_DATE ) select --a.STRT_DATE b.ticket_id ,b.issue_date ,b.resolve_date ,count(strt_date)-1 Day_count --,datename(WEEKDAY,strt_date) Day_of_week --,c.holiday_date from cte2 as a join ticket as b on a.strt_date between b.issue_date and b.resolve_date where datename(WEEKDAY,strt_date) not in ('Saturday','Sunday') and a.STRT_DATE not in (select holiday_date from holiday_cal) group by --a.STRT_DATE b.ticket_id ,b.issue_date ,b.resolve_date option(maxrecursion 0) this will give a correct answer because '2024-12-22' and '2025-01-11' both dates are on Sunday and Saturday
One question I am not clear why did you multiply with 2 for week Including weekends the total days are 20 (first value)
Because of saturday and sunday
For every week, we have 2 weekend, and here, there are 3 weeks, out of which how many weekend will we get ? That's 6. Similarly for 2 weeks, we will get 4 weekend. I agree that the alias is kind of going to get misunderstand. It should be like "weekend_days_cnt" instead of week_cnt, that will save from misunderstanding ig :)
Nice bro ..Keep posting videos
sure.
Thank you so much for sharing with dataset ... making more interesting for me
Thanks 🙏
Very good brother, i learnt for the first time that we can even join tables using such logic
Thank you 🙏
Superb explanation 👌 👏 👍
Thanks, glad you found it helpful! 😊
Wow great 👍
Thanks! 😊
Its out of my mind
Hi, I have a doubt, inner join both table have null values, 1st table have 2 and 2nd table have 1, in inner join we can take one null value for the two tables.
No, null means no value present, so you can't compare.