Finding Number Of Customers On Conditions - 2 Ways | SQL Easy Level Question

  Рет қаралды 40

Select Star

Select Star

Күн бұрын

Пікірлер: 6
@subarnaroyghatak.6590
@subarnaroyghatak.6590 2 ай бұрын
Nice explanation
@select_star_by_anant_negi
@select_star_by_anant_negi 2 ай бұрын
Thanks and welcome
@user-gq6cg3ls7f
@user-gq6cg3ls7f 2 ай бұрын
another approach with cte as( select cx_name, concat(product, ',', LEAD(product) over (partition by cx_name order by cx_name)) next_row, ROW_NUMBER() over (partition by cx_name order by cx_name) RN from purchase_wed ) select count(case when next_row = ('Table,Chair') then 1 END) purchased_both, count(case when next_row = ('Table,') or next_row = ('Table,Table') then 1 END) purchased_table, count(case when next_row = ('Chair,') or next_row = ('Chair,Chair') then 1 END) purchased_chair from cte where RN=1
@select_star_by_anant_negi
@select_star_by_anant_negi 2 ай бұрын
What if someone purchased chair first and then table, next_row = ('Chair','Table')
@user-gq6cg3ls7f
@user-gq6cg3ls7f 2 ай бұрын
@@select_star_by_anant_negi what do you want to display in a column as a output?
@select_star_by_anant_negi
@select_star_by_anant_negi 2 ай бұрын
1. How many customers ordered both table and chair? 2. How many customers ordered only table? 3. How many customers orderedonly chair?
Infosys SQL Interview Question
9:23
Cloud Challengers
Рет қаралды 34 М.
PRANK😂 rate Mark’s kick 1-10 🤕
00:14
Diana Belitskay
Рет қаралды 11 МЛН
У вас там какие таланты ?😂
00:19
Карина Хафизова
Рет қаралды 27 МЛН
7 Database Design Mistakes to Avoid (With Solutions)
11:29
Database Star
Рет қаралды 85 М.
PRANK😂 rate Mark’s kick 1-10 🤕
00:14
Diana Belitskay
Рет қаралды 11 МЛН