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 are the main differences between #temp tables and @table variables and which one is preferred?

1083


Tell me what is use of except clause? How it differs from not in clause?

962


How do you use a subquery to find records that exist in one table and do not exist in another?

1050


Do you know how to store and query spatial data?

1040


can a table be moved to different filegroup? : Sql server administration

979


What are a scheduled jobs or what is a scheduled tasks?

903


As a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this?

1037


your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files? : Sql server administration

985


What is the usage of the sign function?

1115


How to assign new column names in a view?

918


List out the differences between the clustered index and non-clustered index in sql server?

1006


What is a collation in ms sql server?

1087


How to divide query output into multiple groups with the group by clause in ms sql server?

1040


What is the impact on other user sessions when creating indexes?

927


What are the steps to take to improve performance of a poor performing query? : sql server database administration

1054