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 8832757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:36:28+00:00 2026-06-14T08:36:28+00:00

Im having trouble declaring an object from a row so it could be use

  • 0

Im having trouble declaring an object from a row so it could be use in another column

This are the value inserted into a table TRIPLEG with format TripNum#, Length#, Origin, Destination

INSERT INTO TRIPLEG VALUES(10, 1, 'Perth', 'Sydney');
INSERT INTO TRIPLEG VALUES(10, 2, 'Sydney', 'Brisbane');
INSERT INTO TRIPLEG VALUES(11, 1, 'Sydney', 'Melbourne');

How do i actually merge them in a way so it will look like

T#   ORIGIN     DESTINATION1        DESTINATION2
---- ---------- ------------------- ----------------
10   Perth      Sydney              Brisbane
11   Sydney     Melbourne

I was asked to create a relational view, I was guessing it would look something like this:

Create view 
as select t#, origin, destination, destination
from TRIPLEG

But the Destination2 is the part where im not sure what to put.
Could anyone enlighten me on this?

  • 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-06-14T08:36:29+00:00Added an answer on June 14, 2026 at 8:36 am

    How many legs of the trip can there be? 3? 100? What you’re looking for is a crosstab.

    You haven’t indicated what the columns in TRIPLEG are, so I’ll assume t#, leg, origin, destination.

    For the very specific case you have described, this will work:

    SELECT 
    "t#", 
    MAX(DECODE(leg,1,origin)) origin, 
    MAX(DECODE(leg,1,destination)) destination,
    MAX(DECODE(leg,2,destination)) destination2
    FROM TRIPLEG
    GROUP BY "t#"
    

    For just about any other case there are problems with it.

    -If there are more than two legs

    -If leg one finishes in Sydney but leg 2 doesn’t start in Sydney

    etc.

    Try this, investigate crosstabs and ask more questions.

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

Sidebar

Related Questions

I'm having trouble declaring a const field in an abstract class. Why is this?
Having trouble getting this syntax right: SELECT DISTINCT id FROM metadata WHERE (meta_key =
I'm trying to use the boost unordered_multimap class and I'm having trouble declaring it.
Having trouble wrapping a BOOL value in NSValue. I tried this: [NSValue valueWithPointer:[NSNumber numberWithBool:YES]]
I am declaring this Grid Splitter: <GridSplitter HorizontalAlignment=Right VerticalAlignment=Stretch Grid.Column=1 Grid.RowSpan=1 Grid.Row=1 Width=5 Background=#FFBCBCBC
Having trouble understanding how to filter an images table by tag information in a
Having trouble framing this assertion in Rspec for my rails app. A User has
I'm having trouble getting my head around declaring functions dynamically. I tried to ask
I'm having trouble getting a field which is in an object which is inside
I think I'm having trouble with strings and while loops. When I run this

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.