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 happens on checkpoint?

618


How to receive returning result from a query?

586


what is the difference between Tabular and Matrix report?

124


How to create dbo table in sql server?

520


Explain difference between control flow and data flow?

534






Name 3 ways to get an accurate count of the number of records in a table?

577


What is the primary use of the model database?

626


what are database files and filegroups? : Sql server database administration

505


Does the order of columns in update statements matter?

482


What is the difference between local and global temporary tables?

590


How to end a stored procedure properly in ms sql server?

550


What is optimistic concurrency?

567


What number aggregate functions are accessible there in sql?

593


how can a database be repaired? : Sql server administration

521


What the different components of Replication and what is their use?

563