1.Select nth highest salary and name from emp table
2.Select query without using "Like" operator . For eg select employee name start with 'j' and city is 'Noida' in company_name
![withoutusingLike](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_tJaXpU2Fd8KotksC1tJFiSgyQB34XYSLMvWCSjgDDq25_EQ9irS4qX3bzsClHNgI0YttLc-8dukgOF6Q5kFs9Wgh5RSlZUNV4FfYBBwaJb0ihm6tFLFZajhwgTZhaE2kTJEQN0waaTcCXAlqJZlxs=s0-d)
3.Select query for grouping 2 coulmns in one column using Case statement
![screensql](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_u-lHxNtYfpRW0FbYbXwrPpoqLNgMA7zrKI6HqpLJu1ya_DoO5nFTXuQ5cNz-Y6JShD5xza8TtinKAkMPA6i7vkxKTyMMQI3JXbbAfxKDQTBFmmWt38PoLGmQHf46S04PG6aCkbTWVv=s0-d)
4.Create identity like coulmn in query
![rownumber in query](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_s4azP9HhWyB0ut15H9eogFvZmqGQg0B_Caj9m0cpRph1Dn7D95-wmDxdK8oBIir2Z3G_DtJT0Lq-9sPKZUgdXYZaP4ixZlYjVxxtrG5n_mqzLKhP4VRNcfMkbusZH57lK2bUjixe39Jvuj0AMFOlU2=s0-d)
1 2 3 | SELECT DISTINCT (a.empsalary),a.Employee_Name FROM empData A WHERE N =(SELECT COUNT (DISTINCT (b.empsalary)) FROM empData B WHERE a.empsalary<=b.empsalary); --where N is your number (2nd or 5th) e.g SELECT DISTINCT (a.empsalary),a.Employee_Name FROM empData A WHERE 5 =(SELECT COUNT (DISTINCT (b.empsalary)) FROM empData B WHERE a.empsalary<=b.empsalary); |
2.Select query without using "Like" operator . For eg select employee name start with 'j' and city is 'Noida' in company_name
1 | select * from empdata where CHARINDEX('j',Employee_name)=1 and CHARINDEX('Noida',company_name)>0 |
3.Select query for grouping 2 coulmns in one column using Case statement
1 | select result=case when p1 is not null then p1 when p2 is not null then p2 end from tbltest |
4.Create identity like coulmn in query
1 | select row_number () over( order by p1) as sno, result=case when p1 is not null then p1 when p2 is not null then p2 end from tbltest |
Comments
Post a Comment