Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


i have a table student like
sname
-----
ram
ram
ram
raj
raj
raj
i need the output like
sname
-----
ram
raj
ram
raj
ram
raj

Answers were Sorted based on User's Feedback



i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / sagun sawant

;with TEST as (select Row_Number() over (partition by sname
order by sname) as ROWNO,sname from student)
select sname from TEST order by ROWNO,(case when sname
= 'RAM' then 1
when sname = 'RAJ' then 2 end)

Is This Answer Correct ?    9 Yes 1 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / bobby

select ename from (select Row_Number() over (partition by
ename
order by ename) as ROWNO,ename from emp) p
order by ROWNO,ename desc

Is This Answer Correct ?    8 Yes 0 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / shunmuga priya

--The query to work in SQL server 2000
declare @cnt int
select @cnt = count(sname) from student where sname ='ram'

declare @student table
(sname varchar(20))

while @cnt <> 0
begin
insert @student
select * from student where sname like 'raj'
union
select * from student where sname like 'ram'
order by sname desc
set @cnt = @cnt - 1
End

select * from @student

Is This Answer Correct ?    3 Yes 1 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / pradip jain

select sname from (select Row_Number() over (partition by
sname
order by sname) as ROWNO,sname from student) p
order by ROWNO,sname desc


only change table name same as bobby

Is This Answer Correct ?    0 Yes 0 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / murthy

select e.name from
(select *,row_number() over (partition by name order by
name) as Rw from #T1) e
order by e.Rw,name desc

Is This Answer Correct ?    0 Yes 0 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / praveend

This query ill run on MySQL

CREATE TABLE IF NOT EXISTS `stu` (
`id` int(5) DEFAULT NULL,
`sname` varchar(20) DEFAULT NULL
)


INSERT INTO `stu` (`id`, `sname`) VALUES
(1, 'ram'),
(2, 'ram'),
(3, 'ram'),
(4, 'raj'),
(5, 'raj'),
(6, 'raj');

ANSWER
select sname from (
select (id- round((select count(*)from stu)/2)) as id, sname from stu where id >((select count(*)from stu)/2)
UNION
select * from stu where id<4
) as B order by(id)

Is This Answer Correct ?    0 Yes 0 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / mala

select a.tnam,b.tnam from (select tnam from temp where tnam
= 'Ram' ) a,
(select tnam from temp where tnam = 'Raj' ) b

Is This Answer Correct ?    1 Yes 2 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / deepak rohilla

select (substring(name,1,3)+' '+substring(name,13,3)
+' '+substring(name,5,3)+' '+substring(name,17,3)
+' '+substring(name,9,3)+' '+substring(name,21,3))name
from employee where name like '%raj%'

Is This Answer Correct ?    1 Yes 4 No

i have a table student like sname ----- ram ram ram raj raj raj i need the output like sna..

Answer / chitram

select e1.sname,e2.sname from emp e1,emp e2 where e1.sname
= 'ram'
and e2.sname = 'raj';

Is This Answer Correct ?    3 Yes 14 No

Post New Answer

More SQL Server Interview Questions

How to see existing views in ms sql server?

0 Answers  


what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration

0 Answers  


What are commit and rollback in sql?

0 Answers  


What is Extended user-defined?

0 Answers  


How to update muliple row in single query?

0 Answers   MCN Solutions,


What are the 2 types of classifications of constraints in the sql server?

0 Answers  


What's the purpose of Stored Procedure?

6 Answers   Wipro,


sql server has its default date format in da form "yy-mm-dd" its possible to convert da current date format of sql server to desired format. Now my question is dat how to get da previous and comin days date in my desired format??

2 Answers  


hi... this is charan.I persued btech in 2010 looking for a job on database/back-end as freehser. can any seggest me which course or back-end tool i have to learn

0 Answers  


what are the different ways of moving data/databases between servers and databases in sql server? : Sql server database administration

0 Answers  


What is the default fill factor value?

0 Answers  


How to create a store procedure with encryption?

0 Answers  


Categories