Suppose a customer table is having different columns like
customer no, payments.What will be the query to select top three max payments?

1 Answer

Answer :

SELECT customer_no, payments from customer C1
WHERE 3<=(SELECT COUNT(*) from customer C2
WHERE C1.payment <= C2.payment)

Related questions

Description : How is it possible to select generate a select set for the query in the query property sheet?

Last Answer : By using the tables/columns button and then specifying the table and the column names.

Description : What is a difference between pre-select and pre-query?

Last Answer : Fires during the execute query and count query processing after oracle forms constructs the select statement to be issued, but before the statement is actually issued. The pre-query trigger fires ... the query criteria in enter query mode.Pre-query trigger fires before pre-select trigger.

Description : Suppose ORACLE relation R(A, B) currently has tuples {(1, 2), (1, 3), (3, 4)} and relation S(B, C) currently has {(2, 5), (4, 6), (7, 8)}. Consider the following two SQL queries SQ1 and SQ2 ... (A) 2 and 6 respectively (B) 6 and 2 respectively (C) 2 and 4 respectively (D) 4 and 2 respectively

Last Answer : (D) 4 and 2 respectively

Description : How many columns can table have?

Last Answer : The number of columns in a table can range from 1 to 254.

Description : How many LONG columns are allowed in a table ? Is it possible to use LONG columns in WHERE clause or ORDER BY ?

Last Answer : Only one LONG columns is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

Description : Consider the following three SQL queries (Assume the data in the people table) : (a) Select Name from people where Age>21; (b) Select Name from people where Height>180; (c) Select Name from people where (Age>21) or (Height ... number of rows returned by the SQL query (c) ? (A) 3 (B) 7 (C) 10 (D) 21

Last Answer : (C) 10

Description : Select NORTH', CUSTOMER From CUST_DTLS Where REGION = N' Order By CUSTOMER Union Select EAST', CUSTOMER From CUST_DTLS Where REGION = E' Order By CUSTOMER The above is a) Not an error b) Error - ... ' and SOUTH' c) Error - the string should be in double quotes d) Error - ORDER BY clause

Last Answer : d) Error - ORDER BY clause

Description : If the maximum record retrieved property of the query is set to 10 then a summary value will be calculated?

Last Answer : Only for 10 records.

Description : What is a Query Record Group?

Last Answer : A query record group is a record group that has an associated SELECT statement. The columns in a query record group derive their default names, data types, had lengths from the database columns ... rows retrieved by the query associated with that record group. What is a Non Query Record Group?

Description : What is the Difference between a post query and a pre query

Last Answer : A post query will fire for every row that is fetched but the pre query will fire only once.

Description : How you will avoid your query from using indexes?

Last Answer : SELECT * FROM emp Where emp_no+' '=12345; i.e you have to concatenate the column name with space within codes in the where condition. SELECT /*+ FULL(a) */ ename, emp_no from emp where emp_no=1234; i.e using HINTS

Description : What is correlated sub-query ?

Last Answer : Correlated sub query is a sub query which has reference to the main query.

Description : There is a % sign in one field of a column. What will be the query to find it?

Last Answer : '' Should be used before '%'.

Description : How you will avoid duplicating records in a query?

Last Answer : By using DISTINCT

Description : My query was fine last week and now it is slow. Why? (for DBA

Last Answer : The likely cause of this is because the execution plan has changed. Generate a current explain plan of the offending query and compare it to a previous one that was taken when the query was ... the plan should be? Run the query with hints to see if this produces the required performance.

Description : A query fetched 10 records How many times does a PRE-QUERY Trigger and POST-QUERY Trigger will get executed ?

Last Answer : PRE-QUERY fires once. POST-QUERY fires 10 times.

Description : When is PRE-QUERY trigger executed ?

Last Answer : When Execute-query or count-query Package procedures are invoked.

Description : Why query fails sometimes ?

Last Answer : Rollback segment dynamically extent to handle larger transactions entry loads. A single transaction may wipeout all available free space in the Rollback Segment Tablespace. This prevents other user using Rollback segments.

Description : Where is the external query executed at the client or the server?

Last Answer : At the server.

Description : Is it possible to modify an external query in a report which contains it?

Last Answer : No.

Description : If a parameter is used in a query without being previously defined, what diff. exist betw. report 2.0 and 2.5 when the query is applied?

Last Answer : While both reports 2.0 and 2.5 create the parameter, report 2.5 gives a message that a bind parameter has been created.

Description : What is a query?

Last Answer : A query with respect to DBMS relates to user commands that are used to interact with a data base. The query language can be classified into data definition language and data manipulation language.

Description : What is meant by query optimization?

Last Answer : The phase that identifies an efficient execution plan for evaluating a query that has the least estimated cost is referred to as query optimization.

Description : What is Query evaluation engine?

Last Answer : It executes low-level instruction generated by compiler.

Description : maxvalue.sql Select the Nth Highest value from a table?

Last Answer : select level, max('col_name') from my_table where level = '&n' connect by prior ('col_name') > 'col_name') group by level; Example: Given a table called emp with the following columns: -- id number -- name ... , max(sal) from emp -- where level=2 -- connect by prior sal > sal -- group by level

Description : minvalue.sql Select the Nth lowest value from a table?

Last Answer : select level, min('col_name') from my_table where level = '&n' connect by prior ('col_name') < 'col_name') group by level; Example: Given a table called emp with the following columns: -- id number -- name ... , min(sal) from emp -- where level=2 -- connect by prior sal < sal -- group by level

Description : Will a user be able to modify a table with SELECT only privilege?

Last Answer : He won’t be able to UPDATE/INSERT into that table, but for some reason, he will still be able to lock a certain table.

Description : How do you use the same lov for 2 columns

Last Answer : We can use the same lov for 2 columns by passing the return values in global values and using the global values in the code

Description : How many number of columns a record group can have?

Last Answer : A record group can have an unlimited number of columns of type CHAR, LONG, NUMBER, or DATE provided that the total number of column does not exceed 64K.

Description : Can a formula column referred to columns in higher group?

Last Answer : Yes

Description : How many types of columns are there and what are they

Last Answer : Formula columns :: For doing mathematical calculations and returning one value Summary Columns :: For doing summary calculations such as summations etc. Place holder Columns :: These columns are useful for storing the value in a variable

Description : What is pseudo columns ? Name them?

Last Answer : A pseudocolumn behaves like a table column, but is not actually stored in the table. You can select from pseudocolumns, but you cannot insert, update, or delete their values. This section describes these pseudocolumns: * CURRVAL * NEXTVAL * LEVEL * ROWID * ROWNUM

Description : Can a primary key contain more than one columns?

Last Answer : Yes

Description : If a break order is set on a column would it affect columns which are under the column?

Last Answer : No

Description : What are the types of calculated columns available?

Last Answer : Summary, Formula, Placeholder column.

Description : On which columns you should create Indexes?

Last Answer : In general, you should create an index on a column in any of the following situations: ▪ The column is queried frequently ▪ A referential integrity constraint exists on the column ▪ A UNIQUE key ... ORDER BY clauses ▪ On columns that have few of the same values or unique values in the table

Description : Suppose I borrow money from X and I authorize my bank to make monthly payments directly from my checking account. Now, I want more flexibility by paying either online or by check. X refuses to let me do ... tranfers even though its my money and it has no obligation to X. What's the law on this?

Last Answer : answer:Hmm, I suppose you're from USA. Don't know the laws there, but here in Slovenia, we handle things like this by calling and yelling at the lady on the other side and things get fixed eventually. But ... what you can't do with you money. I'd threaten them I'm gonna change the bank or smthng.

Description : A table is having few rows, should you create indexes on this table

Last Answer : Small tables do not require indexes; if a query is taking too long, then the table might have grown from small to large. You can create an index on any column; however, if the ... , creating an index on the column does not increase performance and the index takes up resources unnecessarily.

Description : Suppose t = (1, 2, 4, 3), which of the following is incorrect? a) print(t[3]) b) t[3] = 45 c) print(max(t)) d) print(len(t))

Last Answer : b) t[3] = 45

Description : Suppose list1 is [2445, 133, 12454, 123], what is max(list1) ? a) 2445 b) 133 c) 12454 d) 123

Last Answer : c) 12454

Description : Suppose t = (1, 2, 4, 3), which of the following is incorrect? a) print(t[3]) b) t[3] = 45 c) print(max(t)) d) print(len(t))

Last Answer : d) print(len(t)) is incorrect. In python, len(t) is a built-in function that returns the number of items in the tuple t. Since t contains 4 items, len(t) would correctly return 4. a) print(t[ ... of tuple. c) print(max(t)) is correct, it will return the maximum element of tuple which is 4.

Description : I refinanced 4 months ago to consolidate debt and was suppose to refinance again to get a lower rate. Bank now says can't refinance before 6 months of payments have been made. Is this true?

Last Answer : Untrue. I was promised an immediate refinance and it is 2 1/2 yrs. later and I have not been able to refinance. With Conventional loans there is no seasoning. FHA loans do require 6 months. ... There are obviously other issues which have nothing to do with the number of payments that have been made.

Description : Suppose you have columns of data that span more than one printed page. How can you automatically print the column headings on each page? 1) Click Page Setup on the File menu, click the Sheet tab, ... Page Setup on the File menu, click the Sheet tab, and make a selection under the Print heading

Last Answer : 1) Click Page Setup on the File menu, click the Sheet tab, and enter the row that contains these column

Description : How will you swap objects into a different table space for an existing database ?

Last Answer : Export the user Perform import using the command imp system/manager file=export.dmp indexfile=newrite.sql. This will create all definitions into newfile.sql. Drop necessary objects. Run the script newfile.sql after altering the tablespaces. Import from the backup for the necessary objects.

Description : In a Bank’s database, there are two tables ‘Customer’ and ‘Transaction’ as shown below. Write a query to display customer’s name who has -Technology

Last Answer : (i) Select cust_name from customer c,transaction t where c.Acc_No=t.Acc_No and Transaction_Type= 'Debit';(ii)Select cust_name, t.* from customer c, transaction t where c.Acc_No=t.Acc_No;(iii) ... total amount of all type of transactions, it will only display the total of credit transactions only.

Description : Consider the following schemas: Branch = (Branch-name, Assets, Branch-city) Customer = (Customer-name, Bank-name, Customer-city) Borrow = (Branch-name, loan-number, customer account-number) Deposit = ... )) (C) πcustomer-name(σbalance> 10000(Borrow)) (D) σcustomer-name(σbalance> 10000(Borrow))

Last Answer : (A) πcustomer-name(σbalance> 10000(Deposit)) 

Description : Prepare a table having two columns depicting names of endocrine glands and hormones secreted by them. -Science

Last Answer : Endocrine glands Hormones 1. Pituitary gland (i) Growth hormones 2. Ovaries (ii) Estrogen 3. Testes (iii) Testosterone 4. Thyroid (iv) Thyroxine 5. Pancreas (v) Insulin 6. Adrenal glands (vi) Adrenaline