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

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 user-defined function?

913


Explain ms sql server reporting services vs crystal reports?

855


How to create a view with data from multiple tables?

965


What is the maximum row of a size?

953


how to control the amount of free space in your index pages? : Sql server database administration

982


Can sql servers linked to other servers like oracle?

902


Is it true that rules do not apply to data already existing in a database at the time the rule is created?

989


What is factless fact table? : sql server analysis services, ssas

963


Does partitioning improve performance sql server?

897


What are magic tables in sql server?

1068


what is bit datatype? : Sql server database administration

864


Which command is used for user defined error messages?

1008


Why is replication required on the sql server?

1008


What is table level trigger?

951


What is a transaction and why is it important?

999