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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is field with example?

680


How do users use Report Builder with SQL Server data sources?

129


What is implicit cursors?

746


What is provisioning, billing and metering, and connection routing concepts in the service layer?

109


What is a dataset and what are the different types of datasets?

112






What are number line correlation administrators will use while working with a subquery?

836


Define right outer join in sql server joins?

729


What is a schema in ms sql server 2005?

730


Which are new data types introduced in sql server 2008?

808


Can we add a cpu to sql server?

701


If a table does not have a unique index, can a cursor be opened on it?

666


How many levels of sp nesting are possible?

756


What is a result set object returned by mssql_query()?

736


What is it unwise to create wide clustered index keys?

750


How to rebuild the master database?

748