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 the security principal at the server level that represents your session?
Explain the xml support sql server extends?
What is temporal data type?
is it important for a database administrator to understand the operating system and file access? : Sql server administration
What does select 1 mean?
What is the use of for clause?
Can sql servers link to other servers?
When would you use it?
How to change the data type of an existing column with "alter table" statements in ms sql server?
You are designing a database for your human resources department in the employee table, there is a field for social security number, which cannot contain null values if no value is given, you want a value of unknown to be inserted in this field what is the best approach?
What is a cube? : sql server analysis services, ssas
What is mean by candidate key?
What are the advantages of using stored procedures?
What are the basic features of a trigger in ms sql server?
what is the difference between count(*) and count(1) ?