Hi Mam I regularly follow your videos... Mam in subquery at end of the brackets you need to mention any alphabet then only the query will get executed other wise it given error... Select top 1 sal from (select top 3 sal from emo order by sal desc) s order by sal asc...
@crackconcepts3 жыл бұрын
Yes. You’re right
@danishdude67503 жыл бұрын
@@crackconcepts And you should do a select distinct top N salary in your inner select so you don't get duplicates if more people have the same salary.
@AsifIquebalSarkar3 жыл бұрын
rows can have same salary and we may need to fetch all of them, so WITH TIES would be a better option
@ashutoshanand40403 жыл бұрын
YES I NOTICED THAT AS WELL BUT WHAT IS THE REASON?
@Somnath-je9nd3 жыл бұрын
why s outside that bracket ? can you explain
@akashlondhe11103 жыл бұрын
Instead of select top 1 from (subquery) order by sal desc .. you can write select min(sal) from (subquery)
@maheshtambe95353 жыл бұрын
Good one
@devprakash46713 жыл бұрын
Noice
@kishanmishra73833 жыл бұрын
@@chandrakanthotkar7262 Not necessary. It'll give the output
@karthikgolagani68443 жыл бұрын
@@chandrakanthotkar7262 not needed
@crackconcepts4 жыл бұрын
Hi, do check out the whole SQL Playlist for more such videos!
@anerishah6794 жыл бұрын
Really wonderful explanation!
@manimuttu14 жыл бұрын
Nice explanation!! and please add the playlist url as well :)
@bharatiyadav83333 жыл бұрын
Other clean way is to use limit and offset : "Select sal from Emp Order By sal Desc Limit 1 Offset 2 ;" Limit X Offset Y : select X rows from (Y+1)th row
@user-pr9pq8en2d3 жыл бұрын
I had this in my mind..
@preexa57973 жыл бұрын
Hn re limit use krne ka simple and easy
@sarikadatta37062 жыл бұрын
Thank you Bharati Yadav You made it so much easier. I tried your method and it worked. What she showed in video is logical but for some reason it gives me an error in mysql Thanks a ton for helping me out
@thehavoc63312 жыл бұрын
Damn, this is so easy and in one line, but I don't understand how offset works😅 I understood until LIMIT 1 but how does "offset 2" give you the third highest salary Can anyone explain this to me?
@yogeshwarjoshi3 жыл бұрын
I think you need a distinct for salary otherwise it will fail if few people have same salaries.
@aashishprashant24023 жыл бұрын
Select T.column_name, Dense_Rank() over (order by salary desc) as Rank from T_Tablename where Rank = N;
@universal43343 жыл бұрын
Geeks for geeks
@jv___67293 жыл бұрын
;with rno as ( Select Id, salary , dense_rank() over (order by salary) as salarycte From emp ) Select Id, salary from rno where salarycte = 3
@Jyotisingh-qm4fm3 жыл бұрын
Hello aashis
@vivekkrishnan5143 жыл бұрын
Thanks a lot, you just changed my life. I had watched almost all the videos and attended the interview. I passed 1 written exam and 3 technical rounds and I got selected for the SQL Developer Job only because of you. Thanks a lot for the effort you made. Keep teaching us, videos are really informative and easily understandable. 😇🙏🏻😇
@crackconcepts3 жыл бұрын
I’m so glad my videos helped you. Congratulations on the new job!
@danushhu13173 жыл бұрын
Shata 😂 dengda sariyagi
@ranaprathap82923 жыл бұрын
Bro any requirements for SQL pls reply me
@kushalgupta83533 жыл бұрын
Other Solution: select salary from (select salary from employee order by desc limit 3) order by salary asc limit 1;
@Jagadish123453 жыл бұрын
it’s not a different solution, it’s just different database’s query like top works for mssql where as limit works for mysql and postgresql
@av983 жыл бұрын
@@Jagadish12345 you are right For Oracle it's FETCH
@thinkingmad16853 жыл бұрын
@@Jagadish12345 similar way can you tell for sql plus
@paramvirsohi59223 жыл бұрын
The bestest and the easieST place ON ENTIRE INTERNET TO FIND ANSWER. TYSM. HELPED ME IN INTERVIEW
@pratikkulkarni49293 жыл бұрын
Absolutely super today this is asked in interview for me and today i got this answer
@saiteja52463 жыл бұрын
We can use select * from(select *,rank() over(order by sal desc) rno from emp)src where rno = Nth value
@GANESH-zi2xb3 жыл бұрын
This query is wrong
@himanshugupta48073 жыл бұрын
In case of duplicate your query will not give expected result. We can use dense function instead rank function because rank give pit holes while generating rank on duplicates.
@akulakalyan12423 жыл бұрын
Select * from (select *, denserank() over (partition by empid order by sal desc)a,sal) src where src.a= Nth value;
@himanshugupta48073 жыл бұрын
@@akulakalyan1242 Hey Akula, query seems to be correct just one correction if you do partition over emp id then each salary will become unique and all records will have dense rank =1 so no need to use partition by clause.
@akulakalyan12423 жыл бұрын
@@himanshugupta4807 Then we can use dept id partition right
@vireshmohan75543 жыл бұрын
Hey, just wanted to let u knw that u r amazing.....The explanation Is just awesome...Thnx for such vids...Much Appreciated!!
@dhivyakamalakannan3 жыл бұрын
Love this !! And I wish there was a love button in KZbin for subscribers
@anissiddiqui26494 жыл бұрын
Congratulations for 9 thousand subscribers.
@raveendrakumar44993 жыл бұрын
Excellent explanation, This is really helpful to understand the concept of this. Thank you so much for the video and keep posting interview based videos like this
@lucky4y43 жыл бұрын
Hi, I had watched your videos on SQL and it worked like a miracle for me. My logics gt better and better and finally I got the job offer that too on 31st of December 2020. I could never thank you. Thank you for your help. Keep posting keep helping keep growing. Thank you.
@crackconcepts3 жыл бұрын
Congratulations 👏
@zubairahmed-om4vd3 жыл бұрын
Very informative may Allah bless u
@veenijeyasri25163 жыл бұрын
Excellent mam, keep it up, expect more video from your page like this
@mallikarjunhagargi78303 жыл бұрын
You earned one subscriber dear thank you for the good content,,keep doing we appreciate
@mcaddit68023 жыл бұрын
Why top 1 keyword doesn't support in most of the SQL compiler?
@ramanjaneyulum57393 жыл бұрын
Select max(sal) from emp where salary not in(select distinct top 2 salary from emp order by salary describe)
@rajeshg35703 жыл бұрын
This is very good explanation.. really like it.
@its_me73634 жыл бұрын
very informative video...can you please make videos on more advanced SQL queries like partition, window function and pivoting table etc. ?
@equiwave804 жыл бұрын
I have just just started to learn SQL. These videos will be very useful for for the me!!! BTW I have subscribed to your channel!!!
@ritika293 жыл бұрын
Instead of TOP 1 in the outer query can we use min() function?
@pratikkatke35703 жыл бұрын
Yes u can
@gopikrishna85213 жыл бұрын
Yes u can add min
@parthchoudhary41653 жыл бұрын
Its really helpful .I understand in once ..tyku so much
@guruquebec3 жыл бұрын
Nice and thanks. You should try to teach to pass exams like 70-761 topic wise. since you have good explaining skills.
@anissiddiqui26494 жыл бұрын
Congratulations to 10 thousands subscribers
@crackconcepts4 жыл бұрын
Thank you😀
@ramanmanocha48004 жыл бұрын
Amazing content, eagerly waiting for more videos!!
@RobbyTicknor3 жыл бұрын
You could use a window function kind of like this select * from ( select *,ROW_NUMBER() OVER(ORDER BY sal ASC) AS Row# from emp ) SubQueryWithRowNum where Row# = 3
@ganeshkumaars8593 жыл бұрын
A DIRECT TOP 1 SELECTION MUST DO HOPE SO, AS WE ARE USING DESC AND AGIN MAKING IT ASC ,(the inner query must give result in asc by default)
@RupinderKaur-oq4kl2 жыл бұрын
Thanks alott 💖very easy to understand ☺️
@vishakhaborse72423 жыл бұрын
Your teaching is really amazing...thank you
@lavanyasakhamuri96933 жыл бұрын
Very Nice explanation Mam.
@anirudhsodhani93973 жыл бұрын
what if we have a table that has many duplicate salary values? I think the better way to write the query is to fetch distinct N salary from the tables first ordered in descending order, and then finding out the min out of the N distinct salary/.
@anissiddiqui26493 жыл бұрын
Congratulations for 11 thousands subscribers
@crackconcepts3 жыл бұрын
Thank youu😊
@devanaidu94064 жыл бұрын
Nice answer.. thank you for sharing your knowledge.❤️
@vasanthavasu86963 жыл бұрын
We can use min(sal) in outer query instead of top 1. Am I wright?
@rushikeshkhandagale64723 жыл бұрын
hi thanks for your SQL query lectures they are very helpful.
@ranaprathap82923 жыл бұрын
Bro any requirements for SQL server pls reply me
@AbhishekSharma-hy4nl4 жыл бұрын
Medium level leetcode question ... I just tried to solve it but couldn't. Thnx alot...
@sivaakumalla86874 жыл бұрын
Nice explanation.👍 if it possible explain 'With '
@aravindg48014 жыл бұрын
Hi, From which version onwards TOP clause will work?? In oracle
@talhamuneer25994 жыл бұрын
Please Make Video Every Week!
@Faisal15043 жыл бұрын
Hi After the subquery I had to write as Temp - like give the subquery an alias then it worked. Is that correct way to do this qry? otherwise it says incorrect syntax near keyword order
@surendraavvaru85363 жыл бұрын
Select * from (select ename,esal,dense_rank()over(order by sal desc)rank from Emp) where rank=#
@geniuschess79163 жыл бұрын
perfect explanation ! very well understood :)
@shushmamalhotra65382 жыл бұрын
Mam plz provide a plat form where we can share some question in which we have problem related to SQL query
@akshitdhadwal3 жыл бұрын
You explain things really well
@kumarraju97842 жыл бұрын
Select from emp1 rownum
@beingrishi645010 ай бұрын
Can it be resolved by using row_number OVER clause ORDER BY SALARY DESC ???
@Naresh_91828 ай бұрын
I think this query is not supported by Oracle SQL developer 19thC version
@gbharathi55562 жыл бұрын
Can u say what is the best approach to find n th highest salary....and explain it...
@unknowninformation3529 Жыл бұрын
What about the nth minimum topic? If there is max it should have minimum also right
@kevinj62793 жыл бұрын
We can use aggregate funcs like min(salary) and max(salary) right?
@Prisivi3 жыл бұрын
Yes
@kunaldarwesh24814 жыл бұрын
I like your explanation keep it up.
@arunachaleshwartiruvannama31883 жыл бұрын
Useful one Thanks for this
@parshu32383 жыл бұрын
Very well explain thank you very very much
@hajaaa1003 жыл бұрын
For Nth highest salary in outer query do we need order by salary Asc.??? I feel not required but for 3rd highest it required. Correct me if I am wrong.
@vishalsaxena50813 жыл бұрын
i have a query pls hlp me to solve this column_1 A A1,B2,C5 how can we insert in column like this and after that i want change where A1 is given i need only A pls help
@daminipatil81834 жыл бұрын
Thank u so much Nice explanation
@daminipatil81834 жыл бұрын
Best teaching.. Thank u
@jatinpant69923 жыл бұрын
Mam, I am using MySQL and i am not able to use TOP Query, Please tell me what to do?
@jaisingh16413 жыл бұрын
Why internal query order is descending , why can we keep it ASC , then then later we would not need to order again...
@siddharthkakade77793 жыл бұрын
Select n salary and why do you select top 3 changes the question directly
@AsimSamDesiVines3 жыл бұрын
Ma'am Will it work for repetitive salary data???
@suhas37853 жыл бұрын
Thx for create video like this.....
@mercifulmedia93934 жыл бұрын
Tittle mistake: "Nth" Don't mind.
@Vivek-gx6zd2 жыл бұрын
select salary(select salary from employees order by salary dec)where rownum
@priyaingle8323 жыл бұрын
Wow so easy explaination,
@shubhamingale46253 жыл бұрын
Is there any other trick in which we don't need use inner outer query
@vyshnavib80233 жыл бұрын
writing inner query only sufficient no mam..why can we write outerquery also..explan mam
@mazingTechnical Жыл бұрын
select * from emp order by salary desc limit 2,1;
@xyz-vv5tg2 жыл бұрын
SELECT DISTINCT Sal FROM emps ORDER BY Sal LIMIT n; Here n =3 This might work as well.
@jayantmishra42702 жыл бұрын
3rd height salary:- Can i write like this?? :- Select salary from employees order by salary desc limit 2,1
@MaheshKumar-dj2nj3 жыл бұрын
i use that query subquery worked but above condition not working alert was invalid column name
@chinmayk26572 жыл бұрын
Maam - need help - How to find people in a database who live in the same cities?
@sohrabkhan98233 жыл бұрын
AOA, Urdu may banao na videos mam, or computr pr practical bhi sikhaiye plz
@Swatigowda02223 жыл бұрын
Can you make a video on abstraction in Java please? Because the way you’re teaching is understandable easily.
@rgvlogs12323 жыл бұрын
On this question , Can I use Select max (salary) from sal
@jagadishteluguvlogs2 жыл бұрын
Hlo mam I have one dought ... Given requirement is fetch the highest salary in a table so your are said top 1 salary in a table but but inner query results give 6000,5000,3000 like that but in this salary top 1 salary is 6000 but your said 3000 why mam..plz clearly say that mam IAM full confused..
@CS-Gowtham-R3 жыл бұрын
Hi mam, I need one query. Write a query to select the nth row from the table. In MySQL. Please tell me mam❣️🙏
@raktimghosh75133 жыл бұрын
Select * from Table name where ROWNUM=N;
@CS-Gowtham-R3 жыл бұрын
@@raktimghosh7513 No no it gives 0 to n rows. But I need only the specific nth row.
@sngparminder3 жыл бұрын
I tried but the top query but it is not working, I use toad & my sql
@v_naykp41683 жыл бұрын
Select * from employees Order by Salary Desc Limit 3 ;
@sanjayisure45803 жыл бұрын
I am day by day going depressed bcz of not able to crack interview , they given scinario which is not solve by me , so please help me
@nikhilkadadevar52894 жыл бұрын
Take 3 tables and solve query including all 3 tables mam
@channushahapur30193 жыл бұрын
Can we use order by in the inner query??
@rushikeshkhandagale64723 жыл бұрын
what does mean Data integrity and how we check data integrity ?
@bhavinjoshi67803 жыл бұрын
Hi. How about using limit and offset?
@tanvirkaur50133 жыл бұрын
Limit jus doesnt work in oracle.
@bhavinjoshi67803 жыл бұрын
@@tanvirkaur5013 But here we are talking about MySql. Right? Or no?
@vedantpatil37522 жыл бұрын
Thank you soo much god bless you
@souravnandy8385 Жыл бұрын
Is there any other way to write this query?
@rayavenugopal88473 жыл бұрын
Mam i need full course training on plsql. Can u?
@medhakhairnar61423 жыл бұрын
Thanks ditto same question came in the interview
@mcaddit68023 жыл бұрын
SELECT Salary FROM (SELECT distinct Salary FROM worker ORDER BY salary DESC LIMIT 2) as sal ORDER BY salary LIMIT 1;
@shutzzzzzz4 жыл бұрын
What if we have duplicate data
@AsadAhmad-hd3gn3 жыл бұрын
pahle distinct use karo
@junirox14 жыл бұрын
Hello, really liked your videos. Thank you so much. I have more specific questions regarding SQL and I need help. Can I please email you. KIND REGARDS, JUN FROM UK
@mohammedhanifakolewale172 жыл бұрын
If department Id and salary in the same table how we can find hights salary with respect to department
@mohammedhanifakolewale172 жыл бұрын
I want only display highest salary with respect to department
@isankalp273 жыл бұрын
Hi plz teach us SQL queries on the level of Class 10
@apamwamba6 ай бұрын
Given say: Person Salary tom 10 mary 20 hillary 30 joe 10 apam 200 cecilia 30 zuk 30 hope 80 euphrasia 100 Maureen 150 SELECT [Person] ,[Salary] FROM ( SELECT [Person] ,[Salary] ,DENSE_RANK() OVER (ORDER BY Salary) as ranking FROM [dbo].[sal_01] ) AS x WHERE x.ranking=3 RESULT: Person Salary hillary 30 cecilia 30 zuk 30
@trilok135793 жыл бұрын
I want to display Name with Salary how can i do?
@pratiknarkhede12873 жыл бұрын
Is there a function called Top?
@sngparminder3 жыл бұрын
I wonder not, I tried this query sql toad but didn't worked