I have student marks in a student table. I need second
highest mark .Then what will the query for this?
Answer Posted / sanjay
create table test(id int identity,marks int)
insert into test
select 20
union all
select 31
union all
select 33
union all
select 1
union all
select 3
union all
select 100
union all
select 88
select * from test
with data as
(
select marks,row_number() over(order by marks desc) as rno
from test
)
select * from data where rno = 3
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
How to concatenate two character strings together?
What is the difference between primary key and unique constraints?
What is star, snowflake and star flake schema? : sql server analysis services, ssas
This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?
What are the 10 characteristics of data quality?
How to drop an existing table?
Explain primary key and foreign key constraints?
What does it mean if @@cursor_row returns a negative number?
What is primary key index?
What is a covering index?
What is page in sql server?
what is the difference in login security modes between v6.5 and 7.0? : Sql server database administration
What is explicit mode in sql server?
How to convert numeric values to integers in ms sql server?
Can we use max in where clause?