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 user-defined function?
Explain ms sql server reporting services vs crystal reports?
How to create a view with data from multiple tables?
What is the maximum row of a size?
how to control the amount of free space in your index pages? : Sql server database administration
Can sql servers linked to other servers like oracle?
Is it true that rules do not apply to data already existing in a database at the time the rule is created?
What is factless fact table? : sql server analysis services, ssas
Does partitioning improve performance sql server?
What are magic tables in sql server?
what is bit datatype? : Sql server database administration
Which command is used for user defined error messages?
Why is replication required on the sql server?
What is table level trigger?
What is a transaction and why is it important?