How to formulate SQL Distinct-Statement where there are more that one point per condition?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I want a SQL Select statement that does this:



SELECT DISTINCT Column1,Column2,..,ColumnN FROM TABLE
WHERE whereStatement AND Entries.Count>1


So I want only the Column1 to ColumnN IF there where multiple entries that fullfill the WHERE conditions. The back ground of this is that I want to access curves and something with one point is not a curve. It has at least have to have two points in order to constitute the property curve.



Question: How does one filter for number of entries with a given WHERE condition?



So here is my current strategy:



1 The user selects Materials and a Curve Type



2 The query above is run in order to show the accessible data (here state and material)



Example: For the final data below there would be 4 entries (material1 dry) (material1 conditioned) (material2 dry) (material2 conditioned)



3 In a next step the user can select the conditiones (material state combination) he wants to see as a curve



4 A query is formulated using the selected conditions above



Now the issue is the following: As seen in this query result, material1 has only one entry for 23°C this is not a curve.



enter image description here



A bit background if useful:



I have a oracle material database with a interface for VBA excel. I formulate queries using VBA code. For example is one plot that I get using these queries Modulus vs Temperature. There one or multiple modulus can be stored and if only one is stored this one should not be shown as Temperature vs Modulus.










share|improve this question




















  • 4





    Please share sample data and desired results. It's not clear what you are trying to do here and that will help immensely.

    – JNevill
    Nov 16 '18 at 15:10











  • @JNevill I try to clarify the question in order to make it as understandably as possible.

    – Lucas Raphael Pianegonda
    Nov 16 '18 at 15:20


















1















I want a SQL Select statement that does this:



SELECT DISTINCT Column1,Column2,..,ColumnN FROM TABLE
WHERE whereStatement AND Entries.Count>1


So I want only the Column1 to ColumnN IF there where multiple entries that fullfill the WHERE conditions. The back ground of this is that I want to access curves and something with one point is not a curve. It has at least have to have two points in order to constitute the property curve.



Question: How does one filter for number of entries with a given WHERE condition?



So here is my current strategy:



1 The user selects Materials and a Curve Type



2 The query above is run in order to show the accessible data (here state and material)



Example: For the final data below there would be 4 entries (material1 dry) (material1 conditioned) (material2 dry) (material2 conditioned)



3 In a next step the user can select the conditiones (material state combination) he wants to see as a curve



4 A query is formulated using the selected conditions above



Now the issue is the following: As seen in this query result, material1 has only one entry for 23°C this is not a curve.



enter image description here



A bit background if useful:



I have a oracle material database with a interface for VBA excel. I formulate queries using VBA code. For example is one plot that I get using these queries Modulus vs Temperature. There one or multiple modulus can be stored and if only one is stored this one should not be shown as Temperature vs Modulus.










share|improve this question




















  • 4





    Please share sample data and desired results. It's not clear what you are trying to do here and that will help immensely.

    – JNevill
    Nov 16 '18 at 15:10











  • @JNevill I try to clarify the question in order to make it as understandably as possible.

    – Lucas Raphael Pianegonda
    Nov 16 '18 at 15:20














1












1








1








I want a SQL Select statement that does this:



SELECT DISTINCT Column1,Column2,..,ColumnN FROM TABLE
WHERE whereStatement AND Entries.Count>1


So I want only the Column1 to ColumnN IF there where multiple entries that fullfill the WHERE conditions. The back ground of this is that I want to access curves and something with one point is not a curve. It has at least have to have two points in order to constitute the property curve.



Question: How does one filter for number of entries with a given WHERE condition?



So here is my current strategy:



1 The user selects Materials and a Curve Type



2 The query above is run in order to show the accessible data (here state and material)



Example: For the final data below there would be 4 entries (material1 dry) (material1 conditioned) (material2 dry) (material2 conditioned)



3 In a next step the user can select the conditiones (material state combination) he wants to see as a curve



4 A query is formulated using the selected conditions above



Now the issue is the following: As seen in this query result, material1 has only one entry for 23°C this is not a curve.



enter image description here



A bit background if useful:



I have a oracle material database with a interface for VBA excel. I formulate queries using VBA code. For example is one plot that I get using these queries Modulus vs Temperature. There one or multiple modulus can be stored and if only one is stored this one should not be shown as Temperature vs Modulus.










share|improve this question
















I want a SQL Select statement that does this:



SELECT DISTINCT Column1,Column2,..,ColumnN FROM TABLE
WHERE whereStatement AND Entries.Count>1


So I want only the Column1 to ColumnN IF there where multiple entries that fullfill the WHERE conditions. The back ground of this is that I want to access curves and something with one point is not a curve. It has at least have to have two points in order to constitute the property curve.



Question: How does one filter for number of entries with a given WHERE condition?



So here is my current strategy:



1 The user selects Materials and a Curve Type



2 The query above is run in order to show the accessible data (here state and material)



Example: For the final data below there would be 4 entries (material1 dry) (material1 conditioned) (material2 dry) (material2 conditioned)



3 In a next step the user can select the conditiones (material state combination) he wants to see as a curve



4 A query is formulated using the selected conditions above



Now the issue is the following: As seen in this query result, material1 has only one entry for 23°C this is not a curve.



enter image description here



A bit background if useful:



I have a oracle material database with a interface for VBA excel. I formulate queries using VBA code. For example is one plot that I get using these queries Modulus vs Temperature. There one or multiple modulus can be stored and if only one is stored this one should not be shown as Temperature vs Modulus.







sql oracle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 15:32







Lucas Raphael Pianegonda

















asked Nov 16 '18 at 15:09









Lucas Raphael PianegondaLucas Raphael Pianegonda

637322




637322








  • 4





    Please share sample data and desired results. It's not clear what you are trying to do here and that will help immensely.

    – JNevill
    Nov 16 '18 at 15:10











  • @JNevill I try to clarify the question in order to make it as understandably as possible.

    – Lucas Raphael Pianegonda
    Nov 16 '18 at 15:20














  • 4





    Please share sample data and desired results. It's not clear what you are trying to do here and that will help immensely.

    – JNevill
    Nov 16 '18 at 15:10











  • @JNevill I try to clarify the question in order to make it as understandably as possible.

    – Lucas Raphael Pianegonda
    Nov 16 '18 at 15:20








4




4





Please share sample data and desired results. It's not clear what you are trying to do here and that will help immensely.

– JNevill
Nov 16 '18 at 15:10





Please share sample data and desired results. It's not clear what you are trying to do here and that will help immensely.

– JNevill
Nov 16 '18 at 15:10













@JNevill I try to clarify the question in order to make it as understandably as possible.

– Lucas Raphael Pianegonda
Nov 16 '18 at 15:20





@JNevill I try to clarify the question in order to make it as understandably as possible.

– Lucas Raphael Pianegonda
Nov 16 '18 at 15:20












1 Answer
1






active

oldest

votes


















2














Hmmm, I think a HAVING clause with GROUP BY does what you want:



SELECT Column1, Column2, ..., ColumnN
FROM TABLE
WHERE <where conditions>
GROUP BY Column1, Column2, ..., ColumnN
HAVING COUNT(*) > 1





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340477%2fhow-to-formulate-sql-distinct-statement-where-there-are-more-that-one-point-per%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Hmmm, I think a HAVING clause with GROUP BY does what you want:



    SELECT Column1, Column2, ..., ColumnN
    FROM TABLE
    WHERE <where conditions>
    GROUP BY Column1, Column2, ..., ColumnN
    HAVING COUNT(*) > 1





    share|improve this answer




























      2














      Hmmm, I think a HAVING clause with GROUP BY does what you want:



      SELECT Column1, Column2, ..., ColumnN
      FROM TABLE
      WHERE <where conditions>
      GROUP BY Column1, Column2, ..., ColumnN
      HAVING COUNT(*) > 1





      share|improve this answer


























        2












        2








        2







        Hmmm, I think a HAVING clause with GROUP BY does what you want:



        SELECT Column1, Column2, ..., ColumnN
        FROM TABLE
        WHERE <where conditions>
        GROUP BY Column1, Column2, ..., ColumnN
        HAVING COUNT(*) > 1





        share|improve this answer













        Hmmm, I think a HAVING clause with GROUP BY does what you want:



        SELECT Column1, Column2, ..., ColumnN
        FROM TABLE
        WHERE <where conditions>
        GROUP BY Column1, Column2, ..., ColumnN
        HAVING COUNT(*) > 1






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 15:24









        Gordon LinoffGordon Linoff

        796k37318423




        796k37318423
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340477%2fhow-to-formulate-sql-distinct-statement-where-there-are-more-that-one-point-per%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly