SQL Interview Question With Max and Min Function |

  Рет қаралды 1,856

Coding Lake

Coding Lake

Күн бұрын

Пікірлер: 19
@madarasi360
@madarasi360 21 күн бұрын
Good info keep sharing
@codinglake
@codinglake 21 күн бұрын
thanks.
@nigamsaha6856
@nigamsaha6856 19 күн бұрын
Good information
@anupamjha827
@anupamjha827 10 күн бұрын
We can use first_value
@codinglake
@codinglake 10 күн бұрын
Yes you can use, multiple ways you can solve the problem .
@duraiprabhu4337
@duraiprabhu4337 11 күн бұрын
select state,city,min(population),max(population) from city_info group by (State,City);
@codinglake
@codinglake 11 күн бұрын
Nice one.
@sushmitasaha9083
@sushmitasaha9083 3 күн бұрын
this approach will give state twice and not distinguish between max and min and will display max value under both the columns (same for min)
@KRANTHIKUMARMARADA
@KRANTHIKUMARMARADA 6 күн бұрын
with cte as (select c.*, row_number() over (partition by state order by population) minpop , row_number() over (partition by state order by population desc) maxpop from city_info c) select state, min(case when minpop=1 then city end) minpopulation, min(case when maxpop=1 then city end) maxpopulation from cte group by state
@suhastl3087
@suhastl3087 22 күн бұрын
Didnt get the max(case condition) and min(case condition) how did it eliminate null
@madarasi360
@madarasi360 21 күн бұрын
Group function is eliminated the null value
@codinglake
@codinglake 21 күн бұрын
watch full video then you understand the logic. Don't skip video.
@NikhilKumar-of5ek
@NikhilKumar-of5ek 15 күн бұрын
​@@madarasi360 group by is a clause not a function.
@sachinn5503
@sachinn5503 2 күн бұрын
WITH CTE AS( SELECT *, ROW_NUMBER() OVER(PARTITION BY STATE ORDER BY POPULATION ASC) RANK_LOW, ROW_NUMBER() OVER(PARTITION BY STATE ORDER BY POPULATION DESC) RANK_HIGH FROM CITY_INFO) SELECT STATE,CITY,POPULATION FROM CTE WHERE RANK_LOW=1 OR RANK_HIGH=1 ORDER BY STATE,CITY;
@codinglake
@codinglake Күн бұрын
Nice 👍
@sreesailampavankalyan1007
@sreesailampavankalyan1007 16 күн бұрын
Select state, max(population) as max_population, min(population) as min_population from table Group by state
@codinglake
@codinglake 16 күн бұрын
nice one
@anupamjha827
@anupamjha827 10 күн бұрын
You wont get city name
@saktibiswal6445
@saktibiswal6445 22 күн бұрын
Audio is quite low.
Lead/Lag Window Analytical functions in SQL | Advance SQL concepts
10:34
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
WIPRO SQL Interview Question - FIRST_VALUE( ) Function
11:18
Cloud Challengers
Рет қаралды 18 М.
Roadmap for Learning SQL
4:52
ByteByteGo
Рет қаралды 534 М.