First, select records only when the criteria correspond to?

Hello guys!

I read about a problem all day without finding a solution.

The problem is the following:

I have a vision, which is based on 2 other views including 1 uses a database link. (Not a problem yet because it works as it should!)

In the result of this point of view, I might record n, that have the same attributes 'STR_GEBIET', 'STR_LRT_SUB' and 'INT_QB_NR '.
My intention is to limit the query result to one of these records only. If I had 5 records the same 'STR_GEBIET', 'STR_LRT_SUB' and 'INT_QB_NR' the query must return only one of these recordings and discard the others. If there is no duplicate, he should select all records.

I hope I could explain my problem? I would be really grateful for your contribution to this problem because I don't see any appropriately to solve.
By selecting the rownum does not work with the joined views and so I'm kind of lost.

The select query for my opinion is as follows:
select
x.CNT_QB_MAIN, 
y.LNG_QB_SUB,
x.STR_GEBIET, 
x.STR_LRT_SUB, 
x.INT_LRT_ANTEIL, 
x.STR_BE, 
x.INT_QB_NR, 
x.INT_FLAECHE, 
sum(x.INT_FLAECHE) over (partition by x.INT_QB_NR || x.STR_GEBIET || x.STR_LRT_SUB),
x.INT_TB_NR,
y.STR_BEARBEITER,
y.INT_STATUS,
y.STR_BEMERKUNG,
y.INT_BEZUG_VERJUENG,
y.INT_BEZUG_BESTAND,
y.INT_BEZUG_TOTHOLZ,
y.INT_BEZUG_BIOTOPBAUM,
G.CNT_GEBIET,          
G.STR_NAME,                
G.STR_BESCHREIBUNG         
FROM VT_TBL_GEBIET G
INNER join VT_N2K_LRT_FL X
ON G.CNT_GEBIET = X.STR_GEBIET
LEFT OUTER JOIN VT_TBL_QB Y
ON Y.LNG_QB_SUB = X.CNT_QB_MAIN
Thanks for your help! You are great!

Kind regards
Sebastian

Hello

Have you tried rownum, but have you also tried row_number()?

Something like:

not tested

select *
from ( select x.cnt_qb_main
       ,      y.lng_qb_sub
       ,      x.str_gebiet
       ,      x.str_lrt_sub
       ,      x.int_lrt_anteil
       ,      x.str_be
       ,      x.int_qb_nr
       ,      x.int_flaeche
       ,      sum(x.int_flaeche) over (partition by x.int_qb_nr || x.str_gebiet || x.str_lrt_sub)
       ,      row_number() over (partition by x.int_qb_nr, x.str_gebiet, x.str_lrt_sub order by x.int_qb_nr, x.str_gebiet, x.str_lrt_sub) rn
       ,      x.int_tb_nr
       ,      y.str_bearbeiter
       ,      y.int_status
       ,      y.str_bemerkung
       ,      y.int_bezug_verjueng
       ,      y.int_bezug_bestand
       ,      y.int_bezug_totholz
       ,      y.int_bezug_biotopbaum
       ,      g.cnt_gebiet
       ,      g.str_name
       ,      g.str_beschreibung
       from   vt_tbl_gebiet g
       inner join vt_n2k_lrt_fl x on g.cnt_gebiet = x.str_gebiet
       left outer join vt_tbl_qb y on y.lng_qb_sub = x.cnt_qb_main
     )
where rn=1

And one more thing: creating views on views is something you should avoid.
In your case it is perhaps best to use a view that selects the distinct values for x.int_qb_nr, x.str_gebiet and x.str_lrt_sub instead of limit thereafter by using Analytics already... It'll be less overhead.

Published by: hoek on 2 Sep, 2009 10:47 Oops, removed concats action copy/paste in row_number

Tags: Database

Similar Questions

  • How the LED lights up when a threshold is reached, then turns off only when the value does not reach the threshold for a while?

    Hi, I want to write a program that can turn on the LED when a range of value, this is the threshold and only when the value does not reach the threshold for a period of time, say 5 seconds, then the LED will turn off, otherwise it will remain. How can I achieve this in labview? Can someone help me? Really thanks!

    I assume that you use a while loop to keep the updated value.

    Add a record to offset to your looping it initialize with a U32 (time in ms)

    Add the registry to offset to your loop that keeps the previous value of your bool

    When your reaches the threshold value => the light and set the current time in your shift register.

    In the next iteration of the loop weather check value is still above threshold

    => Y-online previous set to true?

    => Y-online the next iteration

    -Online N => turn switch on and set the current time in your shift register.

    -Online N => subtract the time current less time shift record-online more then 5 seconds?

    => Is => keep turning on

    -Online N => turn given

  • Calling a function only when the State is active

    I turn to find the event just to call a function only when the status is active. In fact, I created a State to display the 'product details' click and once the system changes to this State - I have to perform a function.

    Here's the context:

    Let's say that you are on the home page where you will need to click on a product to see details. By clicking on the product, the State to view the details of the product will be activated and a variable inside the new state you will receive all the data (from the class of product). But I discovered Flex run all States at the beginning and we need to watch how declare our function to make sure that we do not have a null to a variable/object reference. Given that value is moving to the State only when the click event to occur, the process of globalization, execution of all States at the beginning will not have any value yet (for the specific product to deal with in the State of the productDetails). So I can't use creationComplete to perform a simple function like setSpecs(), where all the values (for example, width, height, circumference, diameter, price, etc.) will be instiate specific labels.

    What event to use to call a function internal once we are in the State? Just using the creationComplet and stated if he check the currentState = that I have to work on is not enough. I tried 'activate', 'show', 'enterStage' and many others, but without success. I tried to search the Internet, but it seems that this problem is not popular enough to generate sufficient results.

    But I know that it is possible in the case otherwise it will be is not logical and since Flex work very well with the event, I found the right event. It's something basic I know, but when you do not know, it seems difficult to find! ;-))

    Thanks Greg!

    I agree, this is a better method. So I'll change my SENSITIVITY to use viewStack instead of the State. But the problem persists what that, if we use the viewStack State to launch an event only when the State/viewStack is displayed on the screen.

    I found something that works very well for me: updateComplete.

    First of all, I found this before reading your information about viewStack so it worked very well for the method of the State. That I decided to do a test to viewStack and made the necessary changes to the code to reflect a viewStack navigation and make sure the updateComplete was not within my component (stateProduct.mxml). The system was not able to view the specification as the setSpecs() function was not instantiate when displayed. I added the updateComplete = "{setSpecs ()} ' and everything worked great!" So I conclude that no matter if you are using a viewStack State, the updateComplete event can be used to run or functions only when the component is displayed on the screen.

    Now, I have to make my transition between the State working with viewStack effect! ;-))

    Thanks to Greg for this useful tip!

  • Skype rings only when the application is open

    I have a Skype number for my phone a few days ago and I just noticed a problem. When people try to call me using my Skype number, it sounds only when the application is open and the phone is unlocked. However, people can still call me normally on my Skype ID, it is locked or not currently open to the app. It's a rule I missed when having a Skype number?

    I reset my phone to factory settings and it works now.

  • Skype number rings only when the application is open

    I have a Skype number for my phone a few days ago and I just noticed a problem. When people try to call me using my Skype number, it sounds only when the application is open and the phone is unlocked. However, people can still call me normally on my Skype ID, it is locked or not currently open to the app. It's a rule I missed when with a Skype number?

    (Previously posted this in the Android subforum)

    I reset my phone to factory settings and it works now.

  • Display shuts off and comes back only when the Satellite A210 is restarted

    Hello

    Satellite A210 display goes off in time and returns only when the computer is restarted.
    Duration usual DURATION 30 or 45 minutes

    Please advice
    # Is it a hardware or software problem?
    # Some other face same problem brings advice?

    The machine is a year and a half old runs windows vista Basic that comes with it.

    I reinstalled the drivers card display also the problem remains same

    Hello

    Have you tried an external monitor on the laptop?
    If the external monitor works fine, it seems to be a problem of internal display and must be replaced.

    You use the factory settings on your laptop computer or you have installed your own version of Windows? Before turning to an authorized service provider, you need to restore factory settings to determine if it s a hardware or software problem. With the factory settings, everything should work fine and if not, I think it s a hardware problem.

    Check this box!

  • My Ipad charger charge my iphone 5s only when the phone is turned off

    Hi guys. My Ipad charger charging my iphone 5s only when the phone is turned off. The phone does not recognize if it is on and I can't transfer files with it. Help, please?

    Hey Bigfootinyourface,

    I understand that you have a problem with your iPad charger or cable. Accessories and connectors uncertified can often result in the mentioned behavior. Article in the link below provides information that you may find useful.

    Identify the fakes or not certified lightning connector accessories
    https://support.Apple.com/en-us/HT204566

    See you soon!

  • FM Radio has its out only when the screen of the phone is turned off

    FM Radio has its out only when the phone screen is turned off. Even for the speakers or headphones.

    I SOLVED!
    I had turned on 'Ok Google' and set it listening to "from any screen. Looks like Google to try and listen to all the time and blocks Radio FM output for headphones and speakers

  • Why a normal digital text read like a phone number on my site only when the display on the phone or Tablet?

    Hey everybody.

    I'm working on a website and have an ABN followed of the digital text however it does not read as text on a phone or a tablet. In fact, numbers are invisible and when you click it then numbers and calling area is triggered.

    How can I fix this please.

    Help.

    Double post of why a normal digital text reads like a phone number on my site only when the display on the phone or Tablet?

  • Show LOV only when the field is empty

    Hi all
    My surroundings:
    Oracle 10g on Windows
    Forms [32 bit] Version 9.0.4.1.0 (Production)
    Oracle Database 10 g Enterprise Edition Release 10.2.0.5.0 - 64 bit Production
    With partitioning, OLAP, Data Mining and Real Application Testing options
    Oracle Toolkit Version 9.0.4.1.0 (Production)
    PL/SQL Version 9.0.1.5.1 (Production)

    My problem:
    I have a field in a block, which is text_item and is linked to an element of LOV. I want the LOV appears automatically, whenever I tab in there, only when the element is EMPTY (for example when I try to insert in the block). When, upon request, it should show only the value in the field, and user can choose to activate the LOV, by pressing F9, if she wants to. It now displays automatically each time text agenda is a debate (works very well when the user is inserted, but annoying when she questioned the shape and trying to tab thru.) Every time she focuses on the field, LOV is popping up!)

    The current setting for the property on the element of text field: Type: text element
    The list of values: MY_LOV_NAME
    Validation of list: Yes

    Properties on MY_LOV_NAME
    Auto display: Yes

    Any suggestions? Or trigger level I can use, and if so, what build_in can use?
    New forms and will greatly appreciate advice from pros!

    Thank you
    Libran_girl

    It's very simple,

    IN once - new - item - Instance

    DECLARE
    V_LOV BOOLEAN;
    BEGIN
    IF: NOM_ELEMENT IS NULL
    THEN
    V_LOV = SHOW_LOV (LOV_NAME);
    END IF;
    END;

    Try it, you will get your result, if it doesn't work, try: block_name.item_name

    Abbas

  • return the empty record only when no results not returned by the main query

    It is a question of SQL (not PL/SQL)...

    Let's say I have the following text:

    Full_name SELECT NULL, NULL, NULL last_update_date address
    OF the double
    UNION ALL
    SELECT full_name, address, last_update_date
    Employees
    WHEN TRUNC (sysdate) = TRUNC (last_update_date)

    If the second part of the query retrieves no rows, it works beautifully and I get a blank line; However, if the second part of the query returns records, I get a blank line over my dataset I want.

    How can I create a SQL statement that executes only the first query (before the union all) when no result is returned from the second. Also, I don't want to exceute the query twice only if I can get a count of the records because my actual query is much more complex than the example I've provided here.

    Thanks in advance!
    Emily

    Hello

    You can try to use a subquery factoring (WITH clause)
    The query is executed only once, the query results are cached in memory or in a temporary table.
    and you can view these results several times in the main query:

    WITH second_query AS (
      -- your second query here
      SELECT full_name, address, last_update_date
      FROM employees
      WHERE TRUNC(sysdate)=TRUNC(last_update_date)
    )
    SELECT full_name, address, last_update_date
    FROM second_query
    UNION ALL
    SELECT NULL full_name, NULL address, NULL last_update_date
    FROM dual
    WHERE NOT EXISTS ( SELECT 1 FROM second_query)
    

    Published by: kordirko on 2010-07-08 02:02

  • DeskJet F380 print only page 1 - only when the first powered

    I work under Windows 7. I checked the toner level - not low; cleaning cartridges does not help.  When the power is turned on, the first page prints ok, not strong. The following pages, it acts like it is printing but prints pages white, totally clean.

    Thanks for your suggestions.  I wonder if it's time for a new printer.

    Pablu

    Hi pablu,.

    Welcome to the HP Forums, I hope you enjoy your experience!

    I see you are having some problems printing with Deskjet F380.
    I'll be happy to help you.

    I would disable all the start up programs to make sure that something in the background is not cause printing problems.

    Go to start, run, type msconfig, click on the Services tab.
    Click to select the hide all Microsoft Services check box.
    Click Disable all.

    Click on the tab at the top of the page, select Disable all the startup, apply, OK and restart the computer.

    Temporary disable all Antivirus software.

    Then try to print again.

    You will need to go back and allow all when done and turn on the Antivirus software.

    Let me know how it goes and we'll go from there.

    Thanks for posting on the HP Forums.
    Good day.

  • ADF select several shuttles become read only when the value is

    Hello

    I want to ask about the select oracle ADF that many shuttle.

    Recently, I want to create a shuttle a lot with the pre value is set in the right box, select. When I try to set the value of the shuttle to select several properties. The shuttle many select transformed into an object as input like the image below text

    a.png

    but when I'm not set to select several shuttles it became normal like that

    b.png

    the method that I put in the value property is like that

    public list < BidClassification > getListBidClassificationTaken() {}

    finalClassification = new ArrayList();

    The OperationBinding class method = ADFUtil.getMethodBinding ("retrSupSupplierClassificationFindAllBySupplierId");

    method.getParamsMap () .put ("supplierId", getSelectedSupplier () .getId ());

    List < BidClassification > finalClassification = method.execute () (list < BidClassification >).

    Return finalClassification;

    }

    the method that I use to set the position data is like this

    public list < SelectItem > getListBidClassification() {}

    retval = new ArrayList();

    The OperationBinding class method = ADFUtil.getMethodBinding ("retrBidClassificationFindAll");

    listBidClassification = (list < BidClassification >) method.execute ();

    for (BidClassification bc: listBidClassification) {}

    SelectItem item = new SelectItem();

    item.setLabel (bc.getId ());

    item.setValue (bc);

    retval. Add (Item);

    }

    Return retval;

    }

    I have already replace the method equal in the BidClassification class so there will be no more no problem

    Header 1

    < af:selectManyShuttle label = 'Grading' id = 'sms1"binding =" #{backingBeanScope.backing_vendorEdit.sms1} ' "

    leadingHeader = 'Ranking Master' trailingHeader = 'Grading of provider' >

    < f: selectItems value = "#{backingBeanScope.backing_vendorEdit.listBidClassification}" id = "si1" "

    Binding="#{backingBeanScope.backing_vendorEdit.SI1}"/ >

    < / af:selectManyShuttle >

    This the jsff xml where I put the shuttle several select no defined value

    < af:selectManyShuttle label = 'Grading' id = 'sms1"binding =" #{backingBeanScope.backing_vendorEdit.sms1} ' "

    leadingHeader = 'Ranking Master' trailingHeader = 'ranking of provider.

    value = "#{backingBeanScope.backing_vendorEdit.listBidClassificationTaken}" >

    < f: selectItems value = "#{backingBeanScope.backing_vendorEdit.listBidClassification}" id = "si1" "

    Binding="#{backingBeanScope.backing_vendorEdit.SI1}"/ >

    < / af:selectManyShuttle >

    Select this the jsff xml where I put the shuttle well with the value

    someone has an idea of what's going on with this code? ___. thx a lot btw

    @

    Yeay! I already fix it!

    BTW who behave the same as me.

    You must make a note on the setter and the Get accessor of the variable list you use

    * in my case, I don't implement the setter method and the list setter method

    THX.

  • change should only be updated only when the value of lov

    Hi experts Adf.

    JDeveloper 11.1.1.4.0

    I have a usecase where a lov and a field date is in a table. Each time, I have a lov selects for the first time, and then save the button. Then change date is get inserted with null. (it's fine).

    Now when I change the existing value of the lov and then clicking on save, then the modified date is updated. (it is also very good).

    Scenario question: suppose that in the first row, WE show dropdown because it is saved in the database and change date as null.

    However when I try to change the value to lov ' sales and do not click Save. Now, once I select IT and clicking record. In this case, change date is updated.

    Idle screenplay: Change Date must be updated if there is no modification.

    Untitled.jpg

    If (operation == DML_UPDATE) {}

    setModifyDate (newTimestamp (System.currentMillis));

    }

    You can check the value of publication and skip this step if postedValue is newValue.

    See this example: http://adfcodebits.blogspot.com/2010/07/bit-22-using-getpostedattribute-to.html

    Dario

  • Why have I not two selectable organization even when the pack was created in Creative Packager Cloud?

    Hello

    I have a problem when the pack was created in Creative Cloud Packager, there are two selectable 'same' organisation.

    The first one named "Centre professional of the Littoral Neuchâtelois" offered license type ' named ' or 'license of device.

    The other named "Centre professional of the Littoral Neuchâtelois" (ditto) offered only a license type "named license.

    My question is why do I have two organization?

    Thank you very much.

    Pellaton Roman

    It seems that your ID is associated with two accounts.

    We have an approval attached and the other has a license of creative teams of cloud (username).

    If you want to check more details about these accounts please contact customer service

Maybe you are looking for