error code 1064 when i try to use greater than for aggregate Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!MySQL Error 1153 - Got a packet bigger than 'max_allowed_packet' bytesCan I concatenate multiple MySQL rows into one field?How to output MySQL query results in CSV format?What is the best collation to use for MySQL with PHP?Insert, on duplicate update in PostgreSQL?When should I use cross apply over inner join?How can I do an UPDATE statement with JOIN in SQL?Save PL/pgSQL output from PostgreSQL to a CSV fileSQL select only rows with max value on a columnMySQL error code: 1175 during UPDATE in MySQL Workbench

In musical terms, what properties are varied by the human voice to produce different words / syllables?

Any stored/leased 737s that could substitute for grounded MAXs?

Where did Ptolemy compare the Earth to the distance of fixed stars?

Short story about astronauts fertilizing soil with their own bodies

The test team as an enemy of development? And how can this be avoided?

Trying to understand entropy as a novice in thermodynamics

Find general formula for the terms

The Nth Gryphon Number

My mentor says to set image to Fine instead of RAW — how is this different from JPG?

Flight departed from the gate 5 min before scheduled departure time. Refund options

Why can't fire hurt Daenerys but it did to Jon Snow in season 1?

Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?

New Order #6: Easter Egg

Google .dev domain strangely redirects to https

Pointing to problems without suggesting solutions

Did any compiler fully use 80-bit floating point?

Does the Rock Gnome trait Artificer's Lore apply when you aren't proficient in History?

Sally's older brother

Was the pager message from Nick Fury to Captain Marvel unnecessary?

Is this Half dragon Quaggoth Balanced

How to make triangles with rounded sides and corners? (squircle with 3 sides)

First paper to introduce the "principal-agent problem"

Marquee sign letters

Can gravitational waves pass through a black hole?



error code 1064 when i try to use greater than for aggregate



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!MySQL Error 1153 - Got a packet bigger than 'max_allowed_packet' bytesCan I concatenate multiple MySQL rows into one field?How to output MySQL query results in CSV format?What is the best collation to use for MySQL with PHP?Insert, on duplicate update in PostgreSQL?When should I use cross apply over inner join?How can I do an UPDATE statement with JOIN in SQL?Save PL/pgSQL output from PostgreSQL to a CSV fileSQL select only rows with max value on a columnMySQL error code: 1175 during UPDATE in MySQL Workbench



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








0















 (SELECT discount_percent
FROM products
WHERE discount_percent > AVG(discount_percent)


I'm not sure what im doing wrong










share|improve this question



















  • 1





    Your parentheses aren't balanced.

    – Barmar
    Mar 9 at 0:40






  • 1





    The subquery should just be (SELECT AVG(discount_percent) FROM products)

    – Barmar
    Mar 9 at 0:40

















0















 (SELECT discount_percent
FROM products
WHERE discount_percent > AVG(discount_percent)


I'm not sure what im doing wrong










share|improve this question



















  • 1





    Your parentheses aren't balanced.

    – Barmar
    Mar 9 at 0:40






  • 1





    The subquery should just be (SELECT AVG(discount_percent) FROM products)

    – Barmar
    Mar 9 at 0:40













0












0








0








 (SELECT discount_percent
FROM products
WHERE discount_percent > AVG(discount_percent)


I'm not sure what im doing wrong










share|improve this question
















 (SELECT discount_percent
FROM products
WHERE discount_percent > AVG(discount_percent)


I'm not sure what im doing wrong







mysql sql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 1:06







mandy drew

















asked Mar 9 at 0:34









mandy drewmandy drew

11




11







  • 1





    Your parentheses aren't balanced.

    – Barmar
    Mar 9 at 0:40






  • 1





    The subquery should just be (SELECT AVG(discount_percent) FROM products)

    – Barmar
    Mar 9 at 0:40












  • 1





    Your parentheses aren't balanced.

    – Barmar
    Mar 9 at 0:40






  • 1





    The subquery should just be (SELECT AVG(discount_percent) FROM products)

    – Barmar
    Mar 9 at 0:40







1




1





Your parentheses aren't balanced.

– Barmar
Mar 9 at 0:40





Your parentheses aren't balanced.

– Barmar
Mar 9 at 0:40




1




1





The subquery should just be (SELECT AVG(discount_percent) FROM products)

– Barmar
Mar 9 at 0:40





The subquery should just be (SELECT AVG(discount_percent) FROM products)

– Barmar
Mar 9 at 0:40












2 Answers
2






active

oldest

votes


















2














WHERE discount_percent >
(SELECT discount_percent
FROM products
WHERE discount_percent > AVG(discount_percent)


should be:



WHERE discount_percent > (SELECT AVG(discount_percent) FROM products)


You're missing a closing parenthesis after the subquery. But a bigger problem is that you can't use an aggregation function in the WHERE clause, because aggregation is done after selecting the rows. Also, you need to make the query return just one result so it can be compared with >.






share|improve this answer
































    1














    WHERE discount_percent > AVG(discount_percent)

    probably needs to be changed to
    HAVING discount_percent > AVG(discount_percent)



    The HAVING clause is used to filter on aggregate functions, such as the AVG you are calling.



    For some more documentation on this, check out this link: http://www.mysqltutorial.org/mysql-having.aspx






    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%2f55072837%2ferror-code-1064-when-i-try-to-use-greater-than-for-aggregate%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      WHERE discount_percent >
      (SELECT discount_percent
      FROM products
      WHERE discount_percent > AVG(discount_percent)


      should be:



      WHERE discount_percent > (SELECT AVG(discount_percent) FROM products)


      You're missing a closing parenthesis after the subquery. But a bigger problem is that you can't use an aggregation function in the WHERE clause, because aggregation is done after selecting the rows. Also, you need to make the query return just one result so it can be compared with >.






      share|improve this answer





























        2














        WHERE discount_percent >
        (SELECT discount_percent
        FROM products
        WHERE discount_percent > AVG(discount_percent)


        should be:



        WHERE discount_percent > (SELECT AVG(discount_percent) FROM products)


        You're missing a closing parenthesis after the subquery. But a bigger problem is that you can't use an aggregation function in the WHERE clause, because aggregation is done after selecting the rows. Also, you need to make the query return just one result so it can be compared with >.






        share|improve this answer



























          2












          2








          2







          WHERE discount_percent >
          (SELECT discount_percent
          FROM products
          WHERE discount_percent > AVG(discount_percent)


          should be:



          WHERE discount_percent > (SELECT AVG(discount_percent) FROM products)


          You're missing a closing parenthesis after the subquery. But a bigger problem is that you can't use an aggregation function in the WHERE clause, because aggregation is done after selecting the rows. Also, you need to make the query return just one result so it can be compared with >.






          share|improve this answer















          WHERE discount_percent >
          (SELECT discount_percent
          FROM products
          WHERE discount_percent > AVG(discount_percent)


          should be:



          WHERE discount_percent > (SELECT AVG(discount_percent) FROM products)


          You're missing a closing parenthesis after the subquery. But a bigger problem is that you can't use an aggregation function in the WHERE clause, because aggregation is done after selecting the rows. Also, you need to make the query return just one result so it can be compared with >.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 9 at 4:16









          Gordon Linoff

          800k37321426




          800k37321426










          answered Mar 9 at 0:43









          BarmarBarmar

          438k36262366




          438k36262366























              1














              WHERE discount_percent > AVG(discount_percent)

              probably needs to be changed to
              HAVING discount_percent > AVG(discount_percent)



              The HAVING clause is used to filter on aggregate functions, such as the AVG you are calling.



              For some more documentation on this, check out this link: http://www.mysqltutorial.org/mysql-having.aspx






              share|improve this answer



























                1














                WHERE discount_percent > AVG(discount_percent)

                probably needs to be changed to
                HAVING discount_percent > AVG(discount_percent)



                The HAVING clause is used to filter on aggregate functions, such as the AVG you are calling.



                For some more documentation on this, check out this link: http://www.mysqltutorial.org/mysql-having.aspx






                share|improve this answer

























                  1












                  1








                  1







                  WHERE discount_percent > AVG(discount_percent)

                  probably needs to be changed to
                  HAVING discount_percent > AVG(discount_percent)



                  The HAVING clause is used to filter on aggregate functions, such as the AVG you are calling.



                  For some more documentation on this, check out this link: http://www.mysqltutorial.org/mysql-having.aspx






                  share|improve this answer













                  WHERE discount_percent > AVG(discount_percent)

                  probably needs to be changed to
                  HAVING discount_percent > AVG(discount_percent)



                  The HAVING clause is used to filter on aggregate functions, such as the AVG you are calling.



                  For some more documentation on this, check out this link: http://www.mysqltutorial.org/mysql-having.aspx







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 9 at 0:41









                  Jerry M.Jerry M.

                  7931828




                  7931828



























                      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%2f55072837%2ferror-code-1064-when-i-try-to-use-greater-than-for-aggregate%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

                      AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                      Алба-Юлія

                      Захаров Федір Захарович