return data other columns that depends on only one column group

version Oracle 9.2.0.6

Data
ID, lot, section, dp_number, nbr_of_dwellings, connection_date
"0007958579", 1, 1135994, 0, 0
"0007958579", 2, 1135994, 1, 19670412
136516, '0185510811', 1, 0, 0
"0185510811", 1, 554594, 0, 20061101
"0185510811", 4, 554594, 0, 20061101
"0185510811", 1, 998827, 1, 0

According to the above data, I would like to reproduce an MS Access query that uses the first function in the ' group of ' query '.
Group by on the id column value and max columns nbr_of_dwellings and connection_date

I'm looking results
"0007958579", 1, 1135994, 1, 19670412
"0185510811", 1, 136516, 1, 20061101

Than you for your answer
I'm looking for the query is to be grouped by Id and return the max values for the two columns and the section much Dp_number as a subgroup if I explained this correctly.
i.e.
"0185510811", 11, 136516, 1, 20061101 or
"0185510811", 1, 554594, 1, 20061101 or
"0185510811", 4, 554594, 1, 20061101 or
"0185510811", 1, 998827, 1, 20061101
an acceptable return within the group by ID

Published by: user4147537 on August 2, 2009 22:51

Hello
I think you are looking for, try it. Change with your table name test2.

SELECT   t2.ID, z.lot, z.section, z.dp_number, MAX (t2.nbr_of_dwellings),
         MAX (t2.connection_date)
    FROM test2 t2,
         (SELECT ID, lot, section, dp_number
            FROM (SELECT t2.ID, t2.lot, t2.section, t2.dp_number,
                         ROW_NUMBER () OVER (PARTITION BY t2.ID ORDER BY t2.ID)
                                                                        AS rn
                    FROM test2 t2)
           WHERE rn = 1) z
   WHERE t2.ID = z.ID
GROUP BY t2.ID, z.lot, z.section, z.dp_number;

Output is

---------------             ---------- ----- ----------    ----------   ----------
0185510811               1           998827          1   20061101
0007958579               1          1135994          1   19670412

Please indicate if it helps you or correct

Kind regards
Danish

Published by: Danish on August 3, 2009 11:33

Published by: Danish on August 3, 2009 11:36

Tags: Database

Similar Questions

  • TDMS file creates several tabs data. You want to create only one.

    Hello NOR community,

    I am currently using the DAQ Assistant with my pots of chain record travel over a long time interval (see annex VI). I then use the vi "Write to a file as" to save the data in a file TDMS (see 'Write the file settings' photo attached for all the parameters chosen for the writing of the file). The file is written, however when I open the PDM file, the document creates a tab in Excel for every second of recorded data (please see attachment ""). It seems that the TDMS file is grouping all data every second, and then by creating a new group of data.

    How can I get the file to write all data on a single tab instead of creating multiple? I don't want to concatenate hundreds of tabs in a single great sheet.

    Thank you

    Chris

    You should not use the comment.  I just removed who and everything worked for me.

  • Only one voting group

    Hello

    I design a human task where to do a vote of Group of users to a single group. If I select the voting group, group-> 'Group name', the task is sent to the users in the group. One of them claims that he and responds to the entire group. Not what I want.
    What I want is, that the users in the group will receive the task, for example, 70% agree with the vote and the human task is complete. This behavior occurs when I select voting group and manually add all the users in the group. How can I achieve this?

    Thank you
    João

    Tasks can be assigned to users and groups. In a group vote, if you assign the task to a group, there is only one mission, which is to the group.

    If you want to create a group for each user task in the group, assign users to the group task dynamically using the extension function, ID: getUsersInGroup(groupName, direct, realm). Please see c.7.8 section in the guide to the developer for the details of this function.

  • VM shows two warehouses of data being in use, but use only one?

    Hello

    I am trying to migrate from VMFS3 to VMFS5 and perform this moving VMs to save some data warehouses and then delete/recreate the data with VMFS5 store.

    So far so good, however, I have a VM that signals that it uses two data warehouses. The first is the datatore where it is in fact, the second is a data store where an ISO was mounted on the virtual machine. But even after deleting ISO the VM configuration and proceed to "client" the stills VM shows that store of data as being in use. Other virtual machines that I removed the ISOs don't exhibit this behavior later.

    When I browse the data store, I don't see any references to this particular virtual machine - there is just the folder that contains the ISO standard.

    Is it possible to enumerate what virtual machine actually uses the data store?

    Thank you

    Michael,

    I don't know if it's documented anywhere. I saw this problem a few times with network connections, where the port group was changed to a virtual machine with snapshots.

    André

  • I don't see all my pages recently marked a bookmark and when I try to erase some of see more clears both the original and the copy of other issues when I want only one referenced recently disappeared.

    I have twenty bookmarks in my section recently marked with a bookmark, I copied and their fate. But when I start to remove it Mozilla will remove the copy and the bookmark recently how can I fix that so I can get to the other stuff recently marked with a bookmark?

    If you copy a bookmark in a list of smart folder and paste in another folder, then you create a copy, and you have the bookmark in two folders.

  • HELP I'm a data merge and it gives me only one record per page!

    I really need help here.  I do a fusion of data and that you have selected the options to make more than one record per page, but instead, it is to its own page, merge.  Can someone tell me what I'm missing?

    CS6 seems to have some difficulty to know when there is enough space. The simple solution is to the margins on the right and down the 0 value in the layout options.  And several record preview is known to be buggy. It is best to take a leap of faith and the merger without preview or cancel after you have previewed and before the actual merger.

  • SQL loader is loading only one record

    I use SQL loader to load a CSV file into database

    sqlldr CON CONTROL = 'test.ctl' = 'TEST.log' = bad "bad.bad" LOG DATA = ' test. DAT'

    How ever I always only one record

    CTL file

    OPTIONS (ERRORS = 50)

    DOWNLOAD THE DATA

    ADD

    CONTINUEIF NEXT(1:1) = ' # '.

    IN TABLEtest

    FIELDS TERMINATED BY' '

    SURROUNDED OF POSSIBLY ' "" ' AND ' "'"

    TRAILING NULLCOLS)

    "Etest_ID" (27) TANK.

    'test_IND' CHAR (8),

    'test_SUB_IND' CHAR (12),

    "test_GIND1" TANK (9).

    "test_GIND2" TANK (9).

    'test_STATUS' CHAR (11),

    'test_STATUS' CHAR (11),

    'test_AMOUNT1' CHAR (14).

    'test_AMOUNT2' CHAR (14).

    'test_AMOUNT3' CHAR (14).

    'test_AMOUNT4' CHAR (14).

    "test_GIND21" TANK (9).

    "tet_GIND3" TANK (9).

    'test_STATUS1' CHAR (11),

    'test_STATUS2' CHAR (11),

    'test_AMOUNT1' CHAR (14).

    'test_AMOUNT2' CHAR (14).

    "test_FLAG" TANK (9).

    'test_USED_FLAG' CHAR (15).

    "test_FLAG" TANK (9).

    'TtestL_TRF_AMOUNT' CHAR (16).

    'testF_DATE' CHAR (8),

    'test_STATUS' CHAR (14))

    data file

    'AB00431MT00377_110915_00000 '."PP"."    "« Y »« Y »'TRAN '."FAILURE."'00000008667.15 '.'00000000000.00 '.'00000000000.00 '.'00000000000.00 '.« Y »« Y »'ZERO '.'ZERO '.'00000000000.00 '.'00000000000.00 '.« Y »« Y »" "'00000008667.15 '.'2111014 '.« S »
    'AB00431MT00377_110915_00000 '."PP"."    "« Y »" "'ZERO '."    "'00000000000.00 '.'00000000000.00 '.'00000000000.00 '.'00000000000.00 '.« Y »" "'ZERO '."    "'00000000000.00 '.'00000000000.00 '.« Y »" "" "'00000000000.00 '."0000000".« R »

    Help, please

    I tried generating CTL gall in various Noah this option worked. It is urgent please help

  • Update of iTunes. IPod sync and lost everything but 10 audio books, passed to Touch, four selected works, only on the Touch and not the selected one. Afraid to synchronize other devices that I'll lose everything. ITUNES update BUG

    I updated iTunes 10 Windows a few days ago. I sat to continue listening to an audiobook on my iPod. 110 audio books in sync with the iPod, there are now 10 and not that I want to listen to. I opted for a touch and tried to load the book on that. There are four books selected for the touch. The book I want to not sync and there is only one book on the Touch.  This book is not all the book selected for synchronization.  I am afraid now to sync one of my other devices to iTunes because I'm afraid I might lose even more data.

    Of course, there is a bug in the new update iTunes 12.3.3.17.  Help, please.

    Are audio books in your library? If it is not in your library can see you in your media folder? Your library authorized the Apple ID is used to buy the books? The upgrade of Windows can break the record of the permission on the computer.

    TT2

  • Analyze the failure because that returned data have XML as code

    I have a HTTPService that makes a call to a PHP file to collect some data from a database of vulnerabilities. It works 99.9% of the time. However, there are some cases when I get the following text:

    [CPP faultString = error "" Error #1090: XML parser failure: element is incorrect. "faultCode =" Client.CouldNotDecode"faultDetail ="null"]
    to mx.rpc.http::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::processResult()
    to mx.rpc::AbstractInvoker / http://www.adobe.com/2006/flex/mx/internal::resultHandler()
    at mx.rpc::Responder/result()
    at mx.rpc::AsyncRequest/acknowledge()
    to: DirectHTTPMessageResponder / completeHandler)
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()

    I have debugging in my PHP files and I know with certainty that data are being grouped into XML format suitable for a response back. And when compared to every other answer that works, it's exactly the same (XML sections / tags).

    However, I have noticed that some of the answers are data fields:

    < directory/usr/doc >
    AllowOverride None
    Order deny, allow
    refuse to all the
    allow from localhost
    < / Book >

    Could it be causing my problem? It is not part of my XML, but rather the data returned by the database about a particular vulnerability in Apache.

    Anyone have any ideas on how to deal with this?

    Thank you
    Chris

    Vygo - that's all! Everything works. My PHP was ok, and technically the MXML was ok too. For some reason, I was using an ItemRenderer in the DataGrid control to display the HTMLText. Once I deleted this section:





    And just kept this part:

    He started working. So thank you very much for your time and help!

    Thank you
    Chris

  • script process of sorting (with several column data) and average (some other column data)

    Hello

    I had a lot of help from my log of the bus data, previously.

    My interest now is to sort them according to certain values of the column and then get an average result of them.

    Given that the tiara doesn't seem to support the triage function after loading data, it seems to be a difficult issue for me;

    It would be useful that I can get all related index/approach/function/Council to do this kind of script.

    I've attached a file excel for example.

    In the first "raw" sheet, there are rows of raw data with column names of "year, month, day, ID, ID2, point, condition.

    Actual data had many more columns, but I simplified it for convenience.

    What I try to do is, with the entry (from DialogBox or simply a script as a variable; I can do this) 'year' and 'months' (e.g.: 2015, 6).

    to get the resulting data sheet 'expected results '.

    The result is sorted by value 'ID' and 'condition '. 'Condition' is 0 or 1, then the average of the values of 'point' for each ID and the condition is obtained.

    Group for the 'condition' of 2 will be the average of the results of the 'condition' 0 and 1 (collection of data). (So there are always three groups: for 'condition', 0, 1, and 2.)

    Currently, 'ID' includes 12345 and 54321, but there may be more values, too.

    "Num" column is the number of files RAW allows to get the average for the corresponding 'year-month-ID-condition'.

    Is there an effective approach or the function that you recommend?

    I think that you may need more details for example data, so please do not hesitate to ask me.

    Thanks in advance.

    Inyoung

    The interactive part to modify data in DIAdem is collected in the 'ANALYSIS' left aon tab.

    The second entry, 'Functions of channel' contains 'Values of Channel sorting' method.

    To automate this process, it is possible to use the macro recorder in the tge script module.

  • need to get only one line when you use between (date columns)

    Hi all

    create the table SAMPLE_ITEMS

    (ITEM_NO, varchar2 (10))

    Date DELIVERY_DATE,

    Number of QTY_SUM1

    Number of QTY_SUM2

    Number ITEM_QTY,

    Number ORDER_QTY,

    Number ITEM_AMOUNT,

    Number of SALES_AMOUNT

    );

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 04/2014 ',-88, 0,475,262,-123.45,-1188);

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 05/2014 ', 0, - 122, 475, 262, - 10.234,-1647);

    insert into SAMPLE_ITEMS values ('AAA', ' 16 / 06/2014. ', 0, 0,475,262,-80.59,-135);

    insert into SAMPLE_ITEMS values ('AAA', 19 December 2014 ', 0, 0,475,262,-42.29,-67.5);

    Setting out with my own query,

    ITEM_NOTRUNC (DELIVERY_DATE)QTY_SUM1QTY_SUM2ITEM_QTYORDER_QTYITEM_AMOUNTSALES_AMOUNT
    AAA28/04/2014-880475262-123.45-1188
    AAA28/05/20140-122475262-10.234-1647
    AAA16/06/201400475262-80.59-135
    AAA19/12/201400475262-42.29-67.5

    Every time I question as code

    Select * from SAMPLE_ITEMS

    where DELIVERY_DATE between April 28, 2014 ' and 19 December 2014 '-> they must pass as a parameter

    I need to get only one line

    AAA-88-122475262-256.564-3037.5

    Database 11.2.0.1.0

    Note; Please do not use MAX for Date and do not want to display Date columns in the result

    Note 1: I want to choose DELIVERY_DATE in select it also and only get a line like above the expected result

    SELECT item_no

    SUM (qty_sum1),

    SUM (qty_sum2),

    SUM (DISTINCT item_qty),

    SUM (DISTINCT order_qty),

    SUM (item_amount),

    SUM (sales_amount)

    OF SAMPLE_ITEMS

    WHERE the DELIVERY_DATE BETWEEN TO_DATE (28 April 2014 ', "dd/mm/yyyy")

    AND TO_DATE (19 December 2014 ', "dd/mm/yyyy")

    GROUP BY item_no;

    I will get

    ITEM_NO Trunc (DELIVERY_DATE) QTY_SUM1 QTY_SUM2 ITEM_QTY    ORDER_QTY TTEM_AMOUNT SALES_AMOUNT        

    AAA             12/19/2014                         -88                 -122                475                262                       -256.564              -3037.5

    OK fine, I want to choose DELIVERY_DATE as if so I'll have all the lines, but I want to only show one as shown above

    Because I do report discoverer in Oracle Apps, without taking the DELIVERY_DATE of the select query, it is not possible to move the date as a parameter

    Can you please help me how to do this?

    Thank you

    Post edited by: Rajesh123 NOTE added in the body of the Message

    Post edited by: added test Rajesh123 messages

    Maybe you want a single line in all cases

    Select si.item_no,

    start_date min (d.start_date),

    min (d.end_date) end_date,

    min (si.qty_sum1) qty_sum1,

    min (si.qty_sum2) qty_sum2,

    min (si.item_qty) item_qty,

    min (si.order_qty) order_qty,

    Sum (si.item_amount) item_amount,

    Sum (if. Sales_Amount) sales_amount

    of (start_date select to_date(:date_from,'dd-MON-yyyy'))

    to_date(:date_to,'dd-mon-yyyy') end_date

    of the double

    ) d

    left outer join

    TR sample_items

    on the si.delivery_date between d.start_date and d.end_date

    Group of item_no

    ITEM_NO START_DATE END_DATE QTY_SUM1 QTY_SUM2 ITEM_QTY ORDER_QTY ITEM_AMOUNT SALES_AMOUNT
    - 01/01/1900 31/12/2000 - - - - - -

    Concerning

    Etbin

  • Concatenate the date and time that are stored in two different date columns

    Hello

    I have to select date two columns from two different tables a date and another over time.

    I want to concatenate these two columns and format the result form dd/mm/yyyy hh24

    But I get error invalid number

    For example

    create table as datetime

    (select to_date (' 21/01/2014 ',' dd/mm/yyyy') as dt, to_date('08:00','hh24:mi') like double MC

    )

    Select to_char(dt||) TM, "dd/mm/yyyy hh24") of datetime

    I use oracle 10 g

    Help, please.

    Hello

    Roger wrote:

    ... If you need to take the party date to a date column and the time of anonther part, then you must first convert them to a string, concatenate them and convert them to date.

    You don't need to do this.  What you have described is a way to do it, but this isn't the only way.

    If d1 and d2 are the two DATEs, you can get year, month and day of d1 combined with hours, minutes, and seconds from d2 liike this:

    TRUNC (d1) and (d2 - TRUNC (d2))

    Nesting TO_DATE and TO_CHAR in Oracle, is almost never the best way to do anything.  Oracle provides many functions (for example, TRUNC) to manipulate dates, but also of DATE arithmetic.

  • Hi I would like th different creative cloud buy 2, only photoshop/lightroom one and the other with all pack.is it is possible because I saw that we can only install on 2 different computers at the same time

    Hi I would like th different creative cloud buy 2, only photoshop/lightroom one and the other with all pack.is it is possible because I saw that we can only install on 2 different computers at the same time

    Creative desktop cloud applications can be downloaded and installed on multiple computers, regardless of the operating system. However, the activation is limited to two machines per individual related to the composition, and you may not use the software on these devices simultaneously.

    You can also see:

    FAQ: Can I install Creative Cloud on several computers?

    You can either sign of Creative cloud on a computer to connect to another, or as you said, buy a membership second using an AdobeID different so that you can leave, signed at on 4 computers.

  • Anyone know if there is no CC or BC apps or other alternatives that allow a way to create an online survey consisting of 3 questions for the participants to a trade appear to fill out and submit for the purposes of data collection?  Offlin data collection

    Anyone know if there is no CC or BC apps or other alternatives that allow a way to create an online survey consisting of 3 questions for the participants to a trade appear to fill out and submit for the purposes of data collection?  Offline data collection is a must. Ability to export data to Excel would be an added bonus. Thanks for the tips.

    Hi Nathan,

    This link might help: Create PDF fillable, creative forms of PDF form. Adobe Acrobat DC

    Kind regards

    Sheena

  • How to export data to excel that has 2 tables with the same number of columns and the column names?

    Hi everyone, yet once landed upward with a problem.

    After trying many things to myself, finally decided to post here...

    I created a form in form builder 6i in which clicking on a button, the data gets exported to the excel sheet.

    It works very well with a single table. The problem now is that I cannot do the same with 2 tables.

    Because the tables have the same number of columns and the columns names.

    Here are the 2 tables with column names:

    Table-1 (MONTHLY_PART_1) Table-2 (MONTHLY_PART_2)
    SL_NOSL_NO
    MODELMODEL
    END_DATEEND_DATE
    U-1U-1
    U-2U-2
    U-4U-4
    ..................
    ..................
    U-20U-20
    U-25U-25

    Given that the tables have the same column names, I get the following error :

    402 error at line 103, column 4

    required aliases in the SELECT list of the slider to avoid duplicate column names.

    So how to export data to excel that has 2 tables with the same number of columns and the column names?

    Should I paste the code? Should I publish this query in 'SQL and PL/SQL ' Forum?

    Help me with this please.

    Thank you.

    Wait a second... is this a kind of House of partitioning? Shouldn't it is a union of two tables instead a join?

    see you soon

Maybe you are looking for

  • iPhone adapter 7 Lightning - headphones Bose

    I just bought an iPhone 7 (128 GB) and when trying to read from spotify on my headphones Bose QC20 using the new lightning to 3.5 mm adapter, the control does not work, and the maximum volume is limited compared to my iPhone 6.

  • Is there a way to save all my tabs at once and transfer them to another computer?

    No, I'm not talking about having to first laboriously click each tab, bookmarking them, following the instructions to transfer your Favorites file and them by clicking on each bookmark to reopen your tabs. I wonder about a one click way to save all m

  • Loggin failed

    When I try loggin inhttps://appleid.apple.com/ using my apple id, I'm always questioning security displaying the update of your apple id dialog box. because of, I don't remember security questions, this step cannot be passed by me. I'm trying to find

  • The small screen on my Satellite M size

    Hi you all, AIDS. About the smaller screen size, it's all the time when I use it. Now, I can increase to full size by as I said clicking on display then full screen. But when I start my laptop again after the judgment or the closure of the window I w

  • XC651PA: Change the RAM in the computer hp laptop

    I have a hp pavilion DM4-1024TX entertainment series laptop with 3 GB of ram built-in, but my pc has begun trolling due that I started thinking about the change/upgrade my Ram 8 GB capacity with Corsair 8 gb ram 1600 Mhz ddr3l 1.35v. My question is t