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
What is field with example?
How do users use Report Builder with SQL Server data sources?
What is implicit cursors?
What is provisioning, billing and metering, and connection routing concepts in the service layer?
What is a dataset and what are the different types of datasets?
What are number line correlation administrators will use while working with a subquery?
Define right outer join in sql server joins?
What is a schema in ms sql server 2005?
Which are new data types introduced in sql server 2008?
Can we add a cpu to sql server?
If a table does not have a unique index, can a cursor be opened on it?
How many levels of sp nesting are possible?
What is a result set object returned by mssql_query()?
What is it unwise to create wide clustered index keys?
How to rebuild the master database?