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
Can coalesce return null?
In which tcp/ip port does sql server run? Can it be changed?
How to change server name in sql server?
Why would you call update statistics?
What is difference between joins and subqueries?
What are drillthrough reports?
How much is a sql server license?
What are security principals used in sql server 2005?
Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting is possible?
Is null in sql server?
What is sql server management studio? : sql server management studio
Explain the first normal form(1nf)?
What are statistics?
How to generate create function script on an existing function?
What are database states in ms sql server?