Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6665843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:45:58+00:00 2026-05-26T02:45:58+00:00

Using Oracle 11 I’m wanting to pull data from a table, and add a

  • 0

Using Oracle 11
I’m wanting to pull data from a table, and add a column of calculated values which come from a subquery statement.

Example Table1 is:

COLUMN1:   COLUMN2:
1          Group1
3          Group2
5          Group3
6          Group4

The subquery returns different values each time the query is run, but for the sake of this example let’s say it returns thes values:

2
4
7
8

What I need is to combine the results

COLUMN1:   COLUMN2:    COLUMN3: (subquery - order does NOT matter)
1          Group1      2
3          Group2      4
5          Group3      7
6          Group4      8

But because the subquery is being calculated with each row return from the table, all I am getting is.

COLUMN1:   COLUMN2:    COLUMN3: 
1          Group1      2
3          Group2      2
5          Group3      2
6          Group4      2

There is no way that I can think of to relate the table and the subquery, I’ve tried playing with ROWNUM but with no luck.

UPDATE

SELECT GD.*, N
  FROM patrongroupsdesc GD,
       (SELECT n
          FROM patrongroupsdesc GD2,
               (SELECT n, ROWNUM
                  FROM (    SELECT ROWNUM n
                              FROM DUAL
                        CONNECT BY LEVEL <= 100)
                 WHERE n >= 1) SUB
         WHERE SUB.n = GD2.groupid(+) AND GD2.groupid IS NULL) SUB2

table PATRONGROUPSDESC is formatted as follows

groupid (NUMBER)
description (VARCHAR2)
...other data

SUB returns the values 1-100
SUB2 returns the gaps in groupid numbers
I’m essentially duplicating all data in this table except for one column

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:45:58+00:00Added an answer on May 26, 2026 at 2:45 am

    First you must know that if you don’t have an ORDER BY clause then the order of the results comes with no guarantee at all.

    Then, you can do:

    WITH first_table AS (select *, ROWNUM AS rn FROM ...)
       , secnd_table AS (select *, ROWNUM AS rn FROM ...)
    SELECT first_table.*, secnd_table.*
      FROM first_table INNER JOIN secnd_table USING (rn)
    

    The trick here is that ROWNUM is assigned as a result comes out from a SELECT statement. Therefore if you want to paste tables like this, you must SELECT from your tables and store rownum in another column, and then from those two subselects you can join.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using Oracle, BlazeDS, Java & Flex. I have an ArrayCollection containing data from
Using Oracle, how can I find index names and creation dates from systables/information_schema? How
(Using Oracle) I have a table with key/value pairs like this: create table MESSAGE_INDEX
I'm using oracle to output line items in from a shopping app. Each item
I'm using Oracle Advanced Queues via JMS from within Websphere App Server. Does anyone
Using Oracle 10g, I need to rename a bunch of FK constraints which all
I am using Oracle SQL developer to create a basic table with the following
I'm using Oracle 10g. I have a table with a number of fields of
I'm using Oracle, and I have a very large table. I need to check
I am using Oracle 10g Enterprise edition. A table in our Oracle database stores

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.