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 happens on checkpoint?
How to receive returning result from a query?
what is the difference between Tabular and Matrix report?
How to create dbo table in sql server?
Explain difference between control flow and data flow?
Name 3 ways to get an accurate count of the number of records in a table?
What is the primary use of the model database?
what are database files and filegroups? : Sql server database administration
Does the order of columns in update statements matter?
What is the difference between local and global temporary tables?
How to end a stored procedure properly in ms sql server?
What is optimistic concurrency?
What number aggregate functions are accessible there in sql?
how can a database be repaired? : Sql server administration
What the different components of Replication and what is their use?