5 pts.
 How to select 1 record in DB2
As usual, I often use: select top 1 * from table but in DB2, I can't. I use the Toad tool to input SQL statement. Does anyone have a solution? Please share it with me. Tkanks a lot!

Software/Hardware used:
ASKED: July 16, 2009  5:34 PM
UPDATED: April 18, 2013  2:55 PM

Answer Wiki:
SELECT * FROM <TABLE_NAME>
FETCH FIRST 1 ROW ONLY

-- FOR MULTIPLE ROWS
SELECT * FROM <TABLE_NAME>
FETCH FIRST <NUM> ROWS ONLY
Please let me know if you need any information -Vijay Kanth Hello, In a relational design, you first have to answer the question "first what?" The previous example will return 1 row, but you will never know which row. So don't forget ORDER BY and WHERE clauses. Steve
Last Wiki Answer Submitted:  April 18, 2013  2:55 pm  by  Michael Tidmarsh   11,400 pts.
All Answer Wiki Contributors:  Michael Tidmarsh   11,400 pts. , Svijaykanth   50 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

What if the query is a sub-select?

 10 pts.

 

if in a table a perticular coloumn value is same in no of rows, then how to get tha row count.

 10 pts.

 

…how to get tha row count.
 
Use the COUNT() function. If there is some reason that the same value in multiple rows makes a difference to you, please explain what the difference is. And that probably would mean that you should open a new question because that doesn’t seem to be part of this question thread.
 
Tom

 108,135 pts.