HOW CAN I CREATE A VIEW FROM SAME TABLE WHERE I NEED COLUMNS DETAILS FROM DIFFERENT ROWS IN THE SAME TABLE

i have a table1 on the top, but i want to create a view from table 1 as  view mentioned beneath the table 2. Could any of you please help me.
table1
ID
office
employee
activity
1
246
-9999
698
2
##-99
21480
698
3
104
-9999
7025
4
##-99
88908
7025
5
108
-9999
2415
6
##-99
17135
2415
7
246
-9999
698
8
##-99
21480
698
9
104
-9999
7025
10
##-99
88908
7025
11
108
-9999
2415
12
##-99
17135
2415
view
ID
office
ID1
employee
activity
1
246
2
21480
698
3
104
4
88908
7025
5
108
6
17135
2415
7
246
8
21480
698
9
104
10
88908
7025
11
108
12
17135
2415

declare @forumsTable table (ID int, officeID int, employeeID INT, activityID int)
insert into @forumsTable (ID, officeID, employeeID, activityID)
values
(1 ,246, -9999, 698 ),
(2 ,-99, 21480, 698 ),
(3 ,104, -9999, 7025),
(4 ,-99, 88908, 7025),
(5 ,108, -9999, 2415),
(6 ,-99, 17135, 2415),
(7 ,246, -9999, 698 ),
(8 ,-99, 21480, 698 ),
(9 ,104, -9999, 7025),
(10 ,-99, 88908, 7025),
(11 ,108, -9999, 2415),
(12 ,-99, 17135, 2415)
select f1.ID, f1.officeID, f2.ID as ID1, f1.employeeID, f1.activityID
from @forumsTable f1
inner join @forumsTable f2
on f1.activityID = f2.activityID
and f1.officeID > 0
and f2.employeeID > 0
and f1.id - f2.id = -1
You really need to improve the relationship here.
Perhaps you could make office and activity an exclusive pair.

Similar Messages

  • How can I create a second apple id (without credit card) for my daughter and share it on the same environment?

    Hello, I found some suggestions regarding how to create an account without credit card details for a child, but I'm not shore if it would work harmlessly.
    The following points describe my situation:
    I access the iTunes store from my MacBook Pro, while my 15 year old daughter will access iTunes from her iPad.
    Every time she needs a free download I have to enter my Apple ID in through her iPad.
    When it comes to purchase an app or music for her iPad I do it from my mac and then synchronize with her iPad.
    This is what I’m looking for:
    I would like her to have her personal apple ID that don’t require a credit card so she would be able to log and download the free apps and updates
    I also would like to purchase her software by using my Apple ID linked to my credit card
    I wouldn’t want her to lose the software and on her iPad once logged with a different Apple ID
    Last, I would appreciate to not see the apps downloaded on her iPad appearing on my iPhone: is there a way to have a selective destination for downloaded apps?
    Thank you in advance

    You can create a new account without giving credit card details by following the instructions on this page : http://support.apple.com/kb/HT2534
    And she can then use that account for free items. If she redownloads an item on her iPad (and similarly on your Mac) from an account (either your existing account or a new one) then she may tie the iPad to that account for 90 days (so she won't be able to redownload items from the other account until those 90 days have completed) : http://support.apple.com/kb/HT4627
    Also all content is tied to the account that downloaded it, so only your account will be able to download updates to the apps that were bought/downloaded by your account.
    The apps will only automatically download on your phone if you have automatic downloads turned on in Settings > iTunes & App Store on it.

  • How can I create "drop caps" Anchored frames tool: "Run into Paragraph" in a text document, and at the same time be able to feather the text to the bottom of the pages? I´m using FrameMaker 10.

    @

    Presumably you are doing the DC as a single letter inside an Anchored Frame run-in from left.
    Back when FM had a manual, this was the method discussed in the manual. The manual, however, also said "Framemaker does not feather text in a text frame in which text runs around graphics."
    That was FM7.0. I don't know if FM has enhanced DC or feathering since then.
    If I had the requirement, I might look at putting the whole lead paragraph in a borderless table.

  • How can I create a URL for a PWA for MS Project Server 2010 project file that includes the view?

    Hi, this question has been answered for 2013. The answer here suggests that it can be done in  2010.
    See:
    http://social.technet.microsoft.com/Forums/projectserver/en-US/3affdc4f-36bf-4381-8b75-27c73465efd4/action?threadDisplayName=how-can-i-create-a-url-for-a-pwa-for-ms-project-server-2013-project-file-that-includes-the-view
    Who knows how?
    Regards
    Sander

    Hi Sander,
    As far as I tested it, it is not possible either with PS2010. The URL only contains the PDP name and the projUID.
    Hope this helps,
    Guillaume Rouyre, MBA, MCP, MCTS |

  • How can i create i view?

    Hi
    how can i create i view? give me some docs regarding this

    Hi,
    go thro this link
    /thread/450007 [original link is broken]
    <u></u>Re: i view
    Regards
    Bhargava
    pts r welcome

  • How can I create an internal hyperlink in iWeb? Would like to put an interactive menu at the top of a page.

    How can I create an internal hyperlink in iWeb? Would like to put an interactive menu at the top of a page.

    Do you meant a link to one of your other pages or to a location on one of your pages?  If it's the latter those are called anchors and iWeb does not support them.  However, there are workarounds for that.  See this blog: How to use anchors in iWeb.  If you don't have a lot of widgets on the page it can work fairly well.
    OT

  • How can I make Adobe Acrobat Pro give a warning to another person who is trying to open the same file I currently have open?

    How can I make Adobe Acrobat Pro give a warning to another person who is trying to open the same file I currently have open?

    You can't.

  • How can you create a playlist with music and music video and play those from same playlist through Apple TV?

    How can you create a playlist on Ipod touch with music and music video,  and play those from same playlist through Apple TV?  I can download, create a playlist with both music and music video, stream that through the Apple TV with no problem.  The sound and the information show up on the TV, but when it gets to a music video, it only shows the information and "artwork".
    I also have a video playlist - videos play fine through the Apple TV, but will not shuffle through all videos - continues to repeat the same one.  I have most definitely selected shuffle in both locations - from the playlist and on the ipod video screen while video is playing.

    I finally got it... had to sync the photos with the music in iMovie, arrange the voiceover in GarageBand then export to iTunes, and then I was able to put it all together in iMovie and burn in iDVD... had a few glitches along the way but finally finished : )
    Message was edited by: jpewald

  • How can I create updateable views

    Hi,
    When I create a new page using form --> master detail form, I put one view as the master table and another view as the detail table. By default, the detail table is set as the type SQL Query(updateable report). I guess this is the reason I can add row to the detail table. Then, on the same page, I wanna create another detail table based on another view that will relate to the master table, but this time, I don't have the option to set this detail table as the type(updateable report), just SQL Query and I couldn't add row to this detail table as well.
    So, I just wonder if there is a way to assign more than one view to a master table and the views in the detail table are all updateable(meaning I can insert or delete).
    Thanks!!

    Okay, Here's a quick rundown on how to build a manual form using APEX_ITEM and collections. The process goes in 4 steps: gather the data, display the data, update based on user input, then write the changes. Each step requires it's own piece of code, but you can extend this out as far as you want. I have a complex form that has no less than a master table and 4 children I write to based on user input, so this can get as complex as you need. Let me know if anything doesn't make sense.
    First, create the basic dataset you are going to work with. This usually includes existing data + empty rows for input. Create a Procedure that fires BEFORE HEADER or AFTER HEADER but definitely BEFORE the first region.
    DECLARE
      v_id     NUMBER;
      var1     NUMBER;
      var2     NUMBER;
      var3     VARCHAR2(10);
      var4     VARCHAR2(8);
      cursor c_prepop is
      select KEY, col1, col2, col3, to_char(col4,'MMDDYYYY')
        from table1
        where ...;
      i         NUMBER;
      cntr      NUMBER := 5;  --sets the number of blank rows
    BEGIN
      OPEN c_prepop;
        LOOP
          FETCH c_prepop into v_id, var1, var2, var3, var4;
          EXIT WHEN c_prepop%NOTFOUND;
            APEX_COLLECTION.ADD_MEMBER(
            p_collection_name => 'MY_COLLECTION',
            p_c001 => v_id,  --Primary Key
            p_c002 => var1, --Number placeholder
            p_c003 => var2, --Number placeholder
            p_c004 => var3, --text placeholder
            p_c005 => var4 --Date placeholder
        END LOOP;
      CLOSE c_prepop;
      for i in 1..cntr loop
        APEX_COLLECTION.ADD_MEMBER(
            p_collection_name => 'MY_COLLECTION',
            p_c001 => 0, --designates this as a new record
            p_c002 => 0, --Number placeholder
            p_c003 => 0, --Number placeholder
            p_c004 => NULL, --text placeholder
            p_c005 => to_char(SYSDATE,'MMDDYYYY') --Date placeholder
      end loop;
    END;Now I have a collection populated with rows I can use. In this example I have 2 NUMBERS, a TEXT value, and a DATE value stored as text. Collections can't store DATE datatypes, so you have to cast it to text and play with it that way. The reason is because the user is going to see and manipulate text - not a DATE datatype.
    Now build the form/report region so your users can see/manipulate the data. Here is a sample query:
    SELECT rownum, apex_item.hidden(1, c001),  --Key ID
         apex_item.text(2, c002, 8, 8) VALUE1,
         apex_item.text(3, c003, 3, 3) VALUE2,
         apex_item.text(4, c004, 8, 8) VALUE3,
         apex_item.date_popup(5, null,c005,'MMDDYYYY',10,10) MY_DATE
    FROM APEX_COLLECTIONS
    WHERE COLLECTION_NAME = 'MY_COLLECTION'This will be a report just like an SQL report - you're just pulling the data from the collection. You can still apply the nice formatting, naming, sorting, etc. of a standard report. In the report the user will have 3 "text" values and one Date with Date Picker. You can change the format, just make sure to change it in all four procedures.
    What is critical to note here are the numbers that come right before the column names. These numbers become identifiers in the array used to capture the data. What APEX does is creates an array of up to 50 items it designates as F01-F50. The F is static, but the number following it corresponds to the number in your report declaration above, ie, F01 will contain the primary key value, F02 will contain the first numeric value, etc. While not strictly necessary, it is good practice to assign these values so you don't have to guess.
    One more note: I try to align the c00x values from the columns in the collection with the F0X values in the array to keep myself straight, but they are separate values that do NOT have to match. If you have an application you think might get expanded on, you can leave gaps wherever you want. Keep in mind, however, that you only have 50 array columns to use for data input. That's the limit of the F0X array even though a collection may have up to 1000 values.
    Now you need a way to capture user input. I like to create this as a BEFORE COMPUTATIONS/VALIDATIONS procedure that way the user can see what they changed (even if it is wrong). Use the Validations to catch mistakes.
    declare
      j pls_integer := 0;
    begin
    for j1 in (
      select seq_id from apex_collections
      where collection_name = 'MY_COLLECTION'
      order by seq_id) loop
      j := j+1;
      --VAL1 (number)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>2,p_attr_value=>wwv_flow.g_f02(j));
      --VAL2 (number)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>3,p_attr_value=>wwv_flow.g_f03(j));
      --VAL3 (text)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>4,p_attr_value=>wwv_flow.g_f04(j));
      --VAL4 (Date)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>5,p_attr_value=>wwv_flow.g_f05(j));
    end loop;
    end;Clear as mud? Walk through it slowly. The syntax tells APEX which Collection (p_collection_name), then which row (p_seq), then which column/attribute (p_attr_number) to update with which value (wwv_flow.g_f0X(j)). The attribute number is the column number from the collection without the "c" in front (ie c004 in the collection = attribute 4).
    The last one is your procedure to write the changes to the Database. This one should be a procedure that fires AFTER COMPUTATIONS AND VALIDATIONS. It uses that hidden KEY value to determine whether the row exists and needs to be updated, or new and needs to be inserted.
    declare
    begin
      --Get Hourly Loads from Collection
      for y in (select TO_NUMBER(c001) x_key, TO_NUMBER(c002) x_1,
                 TO_NUMBER(c003) x_2,
                 c004 x_3,
                 TO_DATE(c005,'MMDDYYYY') x_dt
               FROM APEX_COLLECTIONS
               WHERE COLLECTION_NAME = 'MY_COLLECTION') loop
        if y.x_key = 0 then  --New record
            insert into MY_TABLE (KEY_ID, COL1,
                COL2, COL3, COL4, COL5)
              values (SEQ_MY_TABLE.nextval, y.x_1,
                  y.x_2, y.x_3, y.x_4, y.x_dt);
        elsif y.x_key > 0 then  --Existing record
            update MY_TABLE set COL1=x_1, COL2=x_2, COL3=x_3, COL4=x_4, COL5=x_dt
             where KEY_ID = x_key;
        else
          --THROW ERROR CONDITION
        end if;
      end loop;
    end;Now I usually include something to distinguish the empty new rows from the full new rows, but for simplicity I'm not including it here.
    Anyway, this works very well and allows me complete control over what I display on the screen and where all the data goes. I suggest using the APEX forms where you can, but for complex situations, this works nicely. Let me know if you need further clarifications.
    And there you have it.

  • How can I create a horizontal scrollbar with a centered thumb that scrolls content from both sides?

    I am having trouble figuring out how to create a horizontal scrollbar component either by itself or nested inside a data list component that will have it's thumb centered in the track when running and reveal content from either the right or left side when the thumb is moved. The furthest I have managed to get is to create a data list component with a scrollbar component inside that has a centered thumb that reveals content from the right side of the list (0 through 10 of the items) but only reveals blank area when tracking the other way. Is there a way to create say… negative items in the data list… 0 through -10? Or am I approaching this the wrong way. Please help. Thanks.

    Mykola,
    Thanks. I guess I was hoping for an answer that addressed my question from a designer's point of view rather than a developers'. As a designer with over ten years experience using Adobe products for print work it is difficult to understand why "centered" is such a complicated concept when designing art for use on the web. It is so frustrating to realize that most containers for images and text can only be resized by pushing and pulling handles located on the right and bottom; Catalyst seems like a great start but if Adobe really wanted to impress the "design" community it might consider putting all that supercharged code underneath the hood of some more familiar "design" tools. Maybe a "catalytic converter" would allow the introduction of a "centered" tool for every element.
    After all, why is it literally twenty-five times more difficult, requiring the use of three additional programs to create a component that functions exactly like a typical data list and scroll bar with the exception that the thumb is "centered" on the track and reveals images from both the right and left. For that matter why not also have as an option a thumb that snaps to the bottom of the track and reveals images from the top… and one that snaps to the right and reveals images from the left when you run the project? It just seems so logical to expand the scroll bar component to include these options.
    I am very glad to have Catalyst and will redesign my project to fit within the constraints of the tools available in the program but it seems that if Adobe is really serious about Catalyst being a window into the world of web design for designers/AD's that perhaps it might benefit by focusing on what might improve the program from the designer's point of view. I hate to say it but the Catalyst forum is already rife with answers to questions that are riddled with code… Literally. And to be honest most designers don't have the time to decipher that code. As a designer I work regularly and have a deep understanding of Photoshop, InDesign, Illustrator, Acrobat Pro, Final Cut Pro, Final Draft and modo. I do hi-res assembly, retouching, design and layout, identity, production, 3D modeling and rendering, video editing… and before I switch to using Catalyst for web mock-ups I am going to need a more "designer" friendly set of tools and definitely a "centered" control.
    I really think Adobe is fantastic. But I also think it could take a lesson from a great little company called Luxology. I tried learning 3D modeling and rendering for years with programs like Lightwave, Maya and others, always with mixed results. Then Luxology came along and actually delivered on their promise to create a 3D program for artists. What was the factor that made all the difference? Well, besides the Apple award winning interface and sets of tools it was the training available on their sight. The program itself ships with thirty-six hours of quicktime movies. And hundreds more hours available for download. I have never yet not been able to quickly and easily find an answer to a question I had about how to accomplish something in modo. You know how long I have already spent on Adobe TV searching through videos and on the Catalyst forum searching through topics trying to get an answer to what I thought was a very simple question? Way too many. If I have a question about a Luxology product that I can't find the answer to do you know what I do? I call Brad Peebler, the President of Luxology. I'm not special nor do I work for some special development house with special privileges that is simply their policy. And that policy has paid big dividends. Both ILM and Pixar has licensed their technology.
    Well… I apologize for this long response but I really think that if Catalyst is going to attract the market it wants that it will have to consider putting some designers on the development team. After all… Isn't that what the promo videos tout… Finally a web design program for designers. Well, I guess we'll see.
    Karl

  • How can I create a view of top five teams averages based on individual averages of that team?

    I have created a list that groups teams by their Team name (Team column) with the individuals members (participants column) averages and their team average (total average view option).  I want to only display the top five teams that have the overall
    top team averages.  I have a list that contains a team name, average minutes, week, and participant. The team manager plugs in each week a new entry for each participant on the team.  I have a view that computes each team average but I want a view
    of the top five teams based on the top averages of the team (not individual participant average).  Unfortunately, I can only seem to get all teams grouped with individuals of that team, their individual averages and the team average but can't figure out
    only how to show the top five teams top average.  Because it's a total (team average) and not a separate column, I can't get a view by team based on total average.  I can by top individual average but not by the team.  Can some one help me figure
    out a solution?

    A calculated column won't work because a calculated column can only reference the individual item, not the entire list or a subset.
    You could do javascript to build this, but to me it's easier to just use Excel.
    Andy Wessendorf | Solution Foundry [email protected]

  • How can i create a view with jdevlopper 10132

    hi,
    i want to know how to create a view with JDeveloper 10132.
    thanks

    Sorry, but I had to jump in here.
    7rouz - you've certainly violated the 10 commandments for posting here...
    Do you want to:
    1). Create a database view directly in the database
    2). Model a database view using the database modeller
    3). Create an ADF BC View Object
    4). Create some type of visual object (web page, Swing panel)
    5). something else.
    Your question is too ambiguous to yield an answer, unless by luck.
    Regards,
    John

  • How can i create i-views?

    Hii
    Give me some explanation on how to create i-views??

    Hi Subin,
    Please go through this links
    Creating iviews
    http://help.sap.com/saphelp_nw04/helpdata/en/f5/eb50360e6a11d7b84900047582c9f7/frameset.htm
    /people/arunkumar.sampathkumar/blog/2006/09/08/configuring-ep-for-connecting-to-bw
    /people/arunkumar.sampathkumar/blog/2006/09/07/configuring-ep-for-connecting-to-sap-r3
    /people/arunkumar.sampathkumar/blog/2006/08/09/publishing-bw-workbooks-into-portal
    Here is the link to creata a BSP iview.
    http://help.sap.com/saphelp_nw04/helpdata/en/30/1b62799d786445a72ad85acb4fd55b/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/13/81a66d100011d7b84b00047582c9f7/frameset.htm
    Thanks N Regards
    Santosh
    Reward if helpful !!!

  • HT3819 How can you use Home sharing to play music on an xbox 360 for example thats connected to the same WiFi network?

    My console is running under the same WiFi service as my itunes, iphone, and all the content i have saved in my library. How can i link, perhaps through HomeSharing, my content from my phone or computer to my xbox console?

    You can't.  Homesharing allow to share your iTunes content over Apple's devices.  XBox isn't made by Apple but Microsoft.

  • How can I use my IPAD to stream Musik to two Air Port Clients in a network at the same time?

    I want to stream my musik via I PAD to more than one Air Port Clients at the same time. Via MAC it is possible to select "more speaker". In the I PAD I can only select Station 1 or Station 2.

    I opened Airport Utility today and it appears to have been simplified to the point where you can't do much with it these days.
    Yes, welcome to the Fisher Price toy box utility.. where nothing in the way of advanced usage is offered.
    Is there a way to accomplish what I want to do that is reasonably simple?
    You can put time controls onto the offending addresses.
    But if the hackers know anything at all they know how to access the MAC address of the computer and change it.. so the effectiveness of this is limited.
    Change the current setup and password.. You must use WPA2 Personal and I recommend you use a pure alphanumeric password, mix case and numbers of 20 characters or more for your situation.. do not give that password to anyone.. protect the admin password of the TC itself equally well but with a different password. And protect the physical access to the TC from anyone in your home.. because the fact is all security on the TC is an illusion if the TC has open access.
    See how to find passwords here.
    i forgot my password for my router, how can I change them.
    So anyone can discover your passwords without your knowledge and leave no trace on your system.
    If you make no progress.. I suggest replacement of the TC as the main router of your network.. you need something with controls.. and even better controls that allow you to block people.
    The favourite one now is older Netgear WNDR3800 . .you might need to buy from ebay although a few new ones are still around.. alternatively the WNDRMACv2 is simply the same hardware in a white box.. instead of black.
    Load gargoyle firmware onto it.. sorry if I even point to where you can find this info my post will be deleted.. I can say it.. just cannot help further.. so use google.. there are lots of posts and let me assure you this get combo.
    You can continue to use TC at what it does best.. a dumb wireless AP and location for TM backups.

Maybe you are looking for