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

How to download and install sql server 2005 books online?

552


How many triggers you can have on a table?

540


What are the difference between data mart and data warehouse? : sql server analysis services, ssas

512


Is the log file is a part of file group?

556


What do we have to check in database testing?

599






What is dimension table? : sql server analysis services, ssas

568


How can you tell if a database object is invalid?

623


Please differentiate between a local and a global temporary table?

579


What is transactional replication?

565


Difference between LEN() and DATALENGTH() in sql server ?

609


What is the syntax for encrypting a column in SQL Server?

561


What is temporary table in sql server? Why we use temp table?

525


What are the built in functions in sql server?

499


What does Master database contains?

639


Why would you call update statistics?

597