No pseudo columns in DB2

Posted on 2003-03-11
Medium Priority
Last Modified: 2008-01-09
1) Like we have rownum, rowid in oracle, we do not have pseudo columns in DB2.

2) What if we want first few, last few or a range of records in between. How
   do we fetch them.

3) We can use a sequence as one column but that is not the way I would like it.

4) Please give example queries.
Question by:k_murli_krishna
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 17

Author Comment

ID: 8111590
5) There is one specific case: Suppose from main table we can create a temporary table with extra column ID which will contain 1,2,3,4 etc. columns.

6) This we can query with range in where clause. Please give me sample example for this route.

7) More points assured for each good and valid answer.
LVL 13

Accepted Solution

ghp7000 earned 200 total points
ID: 8113661
Sorry, you are out of luck, there is no equivalent rowid or rownum function in DB2 that corresponds to the same functionality as in Oracle. This topic has been debated endlessly. Select statements are not guaranteed to be returned in the order in which they were inserted into the table.

For fetching range of records, use like, between, in, < > etc

There are sequences, identity columns, default values, timestamps and for bit data that can be used to accomplish similar functionality to the rowid function.

for temp tables the syntax is:
with t1 as (select.....),
t2 as (select...)
select .... from t1,t2

(all in one statement, notice that there is no , after last select from temp table t2

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question