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 a coalesce function?
hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.
What are the different types of upgrades that can be performed in sql server?
Explain contrast amongst grouped and non-bunched records?
Explain “@@rowcount” and “@@error” in sql server?
Explain what is use of dbcc commands?
How can you check the level of fragmentation on a table?
How do we know if any query is retrieving a large amount of data or very little data?
What is correlated subquery in sql server?
Explain system rowset functions?
How to convert numeric expression data types using the cast() function?
What is 1nf normalization form?
What Is Rdbms?
What are the requirements for sql server 2016?
What are the different editions available in sql server 2000?