Тёмный

TRICKY SQL Interview Question | SQL Intermediate Question 20 

Code-Con
Подписаться 1,1 тыс.
Просмотров 658
50% 1

Question - Write an SQL query 𝐭𝐨 𝐟𝐢𝐧𝐝 𝐭𝐡𝐞 𝐭𝐱𝐧𝐦𝐨𝐧𝐭𝐡 𝐰𝐡𝐢𝐜𝐡 𝐡𝐚𝐬 𝐭𝐡𝐞 𝐦𝐚𝐱𝐢𝐦𝐮𝐦 𝐭𝐱𝐧𝐚𝐦𝐨𝐮𝐧𝐭
The approach is to arrange the data vertically so that applying aggerate functions becomes easy.
Comment below yours approach too.
create table eshop(txnmonth varchar(50),clothing int,electronics int,sports int);
insert into eshop values('Jan',2000,1500,3000);
insert into eshop values('Feb',1000,2500,4000);
insert into eshop values('Mar',2000,1400,1000);
insert into eshop values('Apr',3000,1500,1000);
select * from eshop;
#amazon #facebook #meta #ai #dataanalytics #placement #college #sql #tcs #cts #infosys

Опубликовано:

 

29 апр 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 6   
@snehithasingam9918
@snehithasingam9918 Месяц назад
explanation 👌
@MusicalShorts-hn1px
@MusicalShorts-hn1px Месяц назад
Thanks for posting the problem along with data set
@saib7231
@saib7231 13 дней назад
Select taxmonth, sum(cast(clothing as int)+cast(electronics as int)+cast(sports as int)) as total_sales From eshop Group by taxmonth order by total_sales desc limit 1 this als works
@harshkumargupta1348
@harshkumargupta1348 Месяц назад
Cant we do this Select taxmonth, Max(clothing+electronics+sports) From eshop Group by 1
@saib7231
@saib7231 13 дней назад
no this is syntax wise all instead you can use this Select taxmonth, sum(cast(clothing as int)+cast(electronics as int)+cast(sports as int)) as total_sales From eshop Group by taxmonth order by total_sales desc limit 1
Далее
How the hell is this done#joker #shorts
00:14
Просмотров 1,1 млн
MySQL SELF JOINS are ... ughhh
10:03
Просмотров 52 тыс.
Database Indexing for Dumb Developers
15:59
Просмотров 43 тыс.