This discussion is archived
1 2 3 Previous Next 37 Replies Latest reply: Jan 4, 2013 12:58 PM by 978776 Go to original post RSS
  • 30. Re: Merging two queries?
    Frank Kulash Guru
    Currently Being Moderated
    Hi,
    570142 wrote:
    Hi again,

    I'll try to explain a little more.
    Your last example is exactly what I'm looking for. But the selection of the materials is done today in the main-query. This is to verify that the material is in the material table.

    I want the selection of materials to the main question type like this: ...
    Sorry, I don't underrstand.

    If you want the code to look a certain way, then change the code however you want.
    If you want the results to look a certain way, then say what results you want, given certain input data (either what you've already posted, or something else that you will post) and certain parameters (as in the target_materials sub-query).
  • 31. Re: Merging two queries?
    978776 Newbie
    Currently Being Moderated
    Hi again,

    It's my bad English that means that I find it hard to explain.

    I want to remove the selection of materials and maintain the results that I get in your last example.
    SELECT     'Label2R1B'     AS material     FROM dual
    I should selects the Period (fromdate and todate) and Plant of this sub-query, and if you want to select the materials you do it in the main-query.
    If you not select any material, the query includes all materials from tblmaterial of the selected Period and Plant.
  • 32. Re: Merging two queries?
    Frank Kulash Guru
    Currently Being Moderated
    Hi,
    570142 wrote:
    Hi again,

    It's my bad English that means that I find it hard to explain.
    If you can't explain well in English, then you have to show very clearly what the problem is with the sample data (and parameters) and the results.
    I want to remove the selection of materials and maintain the results that I get in your last example.
    Are you saying that, even without any target_material, you want the same results as with the following target?
    SELECT     'Label2R1B'     AS material     FROM dual
    Why should the results still include 'Label2R1B'? That material was not found in any period of interest.
    I should selects the Period (fromdate and todate) and Plant of this sub-query, and if you want to select the materials you do it in the main-query.
    If you not select any material, the query includes all materials from tblmaterial of the selected Period and Plant.
    Do you want some other output when there is no target material? If so, post it.
  • 33. Re: Merging two queries?
    978776 Newbie
    Currently Being Moderated
    Hi,
    Frank Kulash wrote:
    Hi,
    Are you saying that, even without any target_material, you want the same results as with the following target?
    SELECT     'Label2R1B'     AS material     FROM dual
    I mean that I want the same output, the material is just one example that I took.
    Why should the results still include 'Label2R1B'? That material was not found in any period of interest.
    'Label2R1B' is just one example that I used. Excuse my lack of clarity.
    Do you want some other output when there is no target material? If so, post it.
    When there is no target material, it should show all materials in all periods. Same output as before...
  • 34. Re: Merging two queries?
    Frank Kulash Guru
    Currently Being Moderated
    Hi,

    Sorry, I don't undersantd any better than before.
    570142 wrote:
    Hi,
    Frank Kulash wrote:
    Hi,
    Are you saying that, even without any target_material, you want the same results as with the following target?
    SELECT     'Label2R1B'     AS material     FROM dual
    I mean that I want the same output, the material is just one example that I took.
    Then run the query I posted earlier. What's the problem?
    Why should the results still include 'Label2R1B'? That material was not found in any period of interest.
    'Label2R1B' is just one example that I used. Excuse my lack of clarity.
    That doesn't explain it at all.
    Do you want some other output when there is no target material? If so, post it.
    When there is no target material, it should show all materials in all periods. Same output as before...
    That's not true. The output you said you wanted before was just one material, 'Lable2R1B'.
  • 35. Re: Merging two queries?
    978776 Newbie
    Currently Being Moderated
    Frank Kulash wrote:
    Hi,

    Sorry, I don't undersantd any better than before.
    I find it hard to explain ... even though it's a little change ..
    That's not true. The output you said you wanted before was just one material, 'Lable2R1B'.
    Your last example is exactly what I need. But I do not want it just to work on material 'Lable2R1B'. It should work on any material or the material you have in a where criteria
  • 36. Re: Merging two queries?
    Frank Kulash Guru
    Currently Being Moderated
    Hi,
    570142 wrote:
    ... I find it hard to explain ... even though it's a little change ..
    I find it hard to help when I don't know what you want.
    That's not true. The output you said you wanted before was just one material, 'Lable2R1B'.
    Your last example is exactly what I need. But I do not want it just to work on material 'Lable2R1B'. It should work on any material or the material you have in a where criteria
    Are you saying that the query I posted works when target_materials contains 1 row ('Label2R1B'), but not in some other situation? If so, what is that other situation? Post the contents of target_materials, and the results you want from the given sample data with the given target_materials.

    If you want taget_materials to contain 0 rows, you can do something like this:
    ...
    ,     target_materials     AS
    (
         SELECT     '?'     AS material     FROM dual
         WHERE     1 = 2
    )
    ...
  • 37. Re: Merging two queries?
    978776 Newbie
    Currently Being Moderated
    Hi,
    Frank Kulash wrote:
    Are you saying that the query I posted works when target_materials contains 1 row ('Label2R1B'), but not in some other situation? If so, what is that other situation? Post the contents of target_materials, and the results you want from the given sample data with the given target_materials.
    Almost, what I mean is that I want selectable target_materials from a table where I have a lot of material.

    Can u help me now?
1 2 3 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points