Changing query to avoid “Aggregations of aggregations are not allowed” in BigqueryInserting multiple rows in a single SQL query?How do I limit the number of rows returned by an Oracle query after ordering?MySQL Query GROUP BY day / month / yearSQL update query using joinsJoin vs. sub-queryHow to query MongoDB with “like”?BigQuery - duplicate rows in query with scoped aggregationGrouped aggregation in Google BigQueryBigQuery avoiding multiple subqueriesAggregate consecutive values BigQuery

Can a stressful Wish's Strength reduction be cured early by a Greater Restoration spell?

What is an acid trap

Have any large aeroplanes been landed — safely and without damage — in locations that they could not be flown away from?

Having to constantly redo everything because I don't know how to do it?

What verb for taking advantage fits in "I don't want to ________ on the friendship"?

If I have the War Caster feat, can I use the Thorn Whip cantrip to stop an enemy caster from escaping using the Dimension Door spell?

Why were the first airplanes "backwards"?

I need help with pasta

Name of transformation that maps numbers outside of interval onto endpoints?

How did they film the Invisible Man being invisible, in 1933?

Missing root certificates on Windows Server 2016 (fresh install)

Ways to get SMD resistors from a strip

Which is better for keeping data: primary partition or logical partition?

Which molecule has maximum bond angle amongst BF₃, BCl₃ and BBr₃?

What game is this character in the Pixels movie from?

List Manipulation : a,b,c,d,e,f,g,h into a,b,c,d,e,f,g,h

Losing queen and then winning the game

Sharing referee/AE report online to point out a grievous error in refereeing

Why isn't UDP with reliability (implemented at Application layer) a substitute of TCP?

Journal standards vs. personal standards

Could human civilization live 150 years in a nuclear-powered aircraft carrier colony without resorting to mass killing/ cannibalism?

Plotting with Precision

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

How can I deal with extreme temperatures in a hotel room?



Changing query to avoid “Aggregations of aggregations are not allowed” in Bigquery


Inserting multiple rows in a single SQL query?How do I limit the number of rows returned by an Oracle query after ordering?MySQL Query GROUP BY day / month / yearSQL update query using joinsJoin vs. sub-queryHow to query MongoDB with “like”?BigQuery - duplicate rows in query with scoped aggregationGrouped aggregation in Google BigQueryBigQuery avoiding multiple subqueriesAggregate consecutive values BigQuery






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Given user and order tables, I need to count users who made their first order on the next day after registration date.



I managed to list such users with the following query:



SELECT 
users.first_name as first_name,
users.last_name as last_name,
users.registration_date as registration_date,
min(orders.order_date) as first_order_date
FROM `users_table` as users
JOIN `orders_table` as orders
ON users.id = orders.user_id
GROUP BY
first_name,
last_name,
registration_date
HAVING
date_diff(first_order_date, registration_date, DAY) = 1
ORDER BY
registration_date ASC
LIMIT 5


Resulting in:



+------------+-----------+-------------------+------------------+
| first_name | last_name | registration_date | first_order_date |
+------------+-----------+-------------------+------------------+
| Albert | Ellis | 2013-04-11 | 2013-04-12 |
| Charles | Moore | 2014-04-29 | 2014-04-30 |
| Jimmy | Payne | 2014-07-01 | 2014-07-02 |
| Angela | Stanley | 2014-10-21 | 2014-10-22 |
| Marie | Bishop | 2014-11-15 | 2014-11-16 |
+------------+-----------+-------------------+------------------+


Now, I can't wrap my head around counting them. When I try something like:



SELECT 
count(date_diff(min(orders.order_date), users.registration_date, DAY) = 1)
FROM `users_table` as users
JOIN `orders_table` as orders
ON users.id = orders.user_id


I receive "Aggregations of aggregations are not allowed" error. How do I amend query to resolve that?










share|improve this question




























    1















    Given user and order tables, I need to count users who made their first order on the next day after registration date.



    I managed to list such users with the following query:



    SELECT 
    users.first_name as first_name,
    users.last_name as last_name,
    users.registration_date as registration_date,
    min(orders.order_date) as first_order_date
    FROM `users_table` as users
    JOIN `orders_table` as orders
    ON users.id = orders.user_id
    GROUP BY
    first_name,
    last_name,
    registration_date
    HAVING
    date_diff(first_order_date, registration_date, DAY) = 1
    ORDER BY
    registration_date ASC
    LIMIT 5


    Resulting in:



    +------------+-----------+-------------------+------------------+
    | first_name | last_name | registration_date | first_order_date |
    +------------+-----------+-------------------+------------------+
    | Albert | Ellis | 2013-04-11 | 2013-04-12 |
    | Charles | Moore | 2014-04-29 | 2014-04-30 |
    | Jimmy | Payne | 2014-07-01 | 2014-07-02 |
    | Angela | Stanley | 2014-10-21 | 2014-10-22 |
    | Marie | Bishop | 2014-11-15 | 2014-11-16 |
    +------------+-----------+-------------------+------------------+


    Now, I can't wrap my head around counting them. When I try something like:



    SELECT 
    count(date_diff(min(orders.order_date), users.registration_date, DAY) = 1)
    FROM `users_table` as users
    JOIN `orders_table` as orders
    ON users.id = orders.user_id


    I receive "Aggregations of aggregations are not allowed" error. How do I amend query to resolve that?










    share|improve this question
























      1












      1








      1








      Given user and order tables, I need to count users who made their first order on the next day after registration date.



      I managed to list such users with the following query:



      SELECT 
      users.first_name as first_name,
      users.last_name as last_name,
      users.registration_date as registration_date,
      min(orders.order_date) as first_order_date
      FROM `users_table` as users
      JOIN `orders_table` as orders
      ON users.id = orders.user_id
      GROUP BY
      first_name,
      last_name,
      registration_date
      HAVING
      date_diff(first_order_date, registration_date, DAY) = 1
      ORDER BY
      registration_date ASC
      LIMIT 5


      Resulting in:



      +------------+-----------+-------------------+------------------+
      | first_name | last_name | registration_date | first_order_date |
      +------------+-----------+-------------------+------------------+
      | Albert | Ellis | 2013-04-11 | 2013-04-12 |
      | Charles | Moore | 2014-04-29 | 2014-04-30 |
      | Jimmy | Payne | 2014-07-01 | 2014-07-02 |
      | Angela | Stanley | 2014-10-21 | 2014-10-22 |
      | Marie | Bishop | 2014-11-15 | 2014-11-16 |
      +------------+-----------+-------------------+------------------+


      Now, I can't wrap my head around counting them. When I try something like:



      SELECT 
      count(date_diff(min(orders.order_date), users.registration_date, DAY) = 1)
      FROM `users_table` as users
      JOIN `orders_table` as orders
      ON users.id = orders.user_id


      I receive "Aggregations of aggregations are not allowed" error. How do I amend query to resolve that?










      share|improve this question














      Given user and order tables, I need to count users who made their first order on the next day after registration date.



      I managed to list such users with the following query:



      SELECT 
      users.first_name as first_name,
      users.last_name as last_name,
      users.registration_date as registration_date,
      min(orders.order_date) as first_order_date
      FROM `users_table` as users
      JOIN `orders_table` as orders
      ON users.id = orders.user_id
      GROUP BY
      first_name,
      last_name,
      registration_date
      HAVING
      date_diff(first_order_date, registration_date, DAY) = 1
      ORDER BY
      registration_date ASC
      LIMIT 5


      Resulting in:



      +------------+-----------+-------------------+------------------+
      | first_name | last_name | registration_date | first_order_date |
      +------------+-----------+-------------------+------------------+
      | Albert | Ellis | 2013-04-11 | 2013-04-12 |
      | Charles | Moore | 2014-04-29 | 2014-04-30 |
      | Jimmy | Payne | 2014-07-01 | 2014-07-02 |
      | Angela | Stanley | 2014-10-21 | 2014-10-22 |
      | Marie | Bishop | 2014-11-15 | 2014-11-16 |
      +------------+-----------+-------------------+------------------+


      Now, I can't wrap my head around counting them. When I try something like:



      SELECT 
      count(date_diff(min(orders.order_date), users.registration_date, DAY) = 1)
      FROM `users_table` as users
      JOIN `orders_table` as orders
      ON users.id = orders.user_id


      I receive "Aggregations of aggregations are not allowed" error. How do I amend query to resolve that?







      sql google-bigquery






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 14:40









      Vadim TikanovVadim Tikanov

      2662 silver badges18 bronze badges




      2662 silver badges18 bronze badges






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Below is for BigQuery Standard SQL



          #standardSQL
          SELECT COUNT(1) next_day_order_users
          FROM `project.dataset.users_table` AS users
          JOIN (
          SELECT user_id, MIN(order_date) first_order_date
          FROM `project.dataset.orders_table`
          GROUP BY user_id
          ) AS orders
          ON users.id = orders.user_id
          WHERE DATE_DIFF(first_order_date, registration_date, DAY) = 1





          share|improve this answer























          • Makes sense, thank you

            – Vadim Tikanov
            Mar 26 at 21:49


















          2














          Just put your query into subquery. You are already choosing clients who ordered next day after registration. So answer is a number of rows in your query



          select count(1)
          from ( SELECT
          users.first_name as first_name,
          users.last_name as last_name,
          users.registration_date as registration_date,
          min(orders.order_date) as first_order_date
          FROM `users_table` as users
          JOIN `orders_table` as orders
          ON users.id = orders.user_id
          GROUP BY
          first_name,
          last_name,
          registration_date
          HAVING
          date_diff(first_order_date, registration_date, DAY) = 1 ) x





          share|improve this answer























          • That worked, thank you. Are nested SELECTs a common practice? Or there might be more elegant solution here?

            – Vadim Tikanov
            Mar 25 at 14:56












          • It's very common practice. Of course there are different solutions to your problem, one of them is nested table

            – lypskee
            Mar 25 at 15:04


















          0














          Why not just use a JOIN condition?



          SELECT COUNT(DISTINCT u.id)
          FROM `users_table` u JOIN
          `orders_table` o
          ON u.id = o.user_id AND
          date_diff(o.order_date, u.registration_date, DAY) = 1;


          The COUNT(DISTINCT accounts for the fact that users could have multiple orders in one day.






          share|improve this answer























          • User's got several orders with different dates. I need the date of first order for comparison. When trying "date_diff(min(orders.order_date), users.registration_date, DAY)" I receive "Aggregate function MIN not allowed in JOIN ON clause".

            – Vadim Tikanov
            Mar 25 at 15:12











          • Is it possible for a user to make an order before that date?

            – Gordon Linoff
            Mar 25 at 15:22











          • There are several orders per user. E.g. user had registered on November 1st and made 3 orders on November 2nd, November 5th and November 21st. I need to count ones, who made their first order right on the next day after registration. They can't make orders before registration.

            – Vadim Tikanov
            Mar 25 at 15:27














          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%2f55340323%2fchanging-query-to-avoid-aggregations-of-aggregations-are-not-allowed-in-bigque%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Below is for BigQuery Standard SQL



          #standardSQL
          SELECT COUNT(1) next_day_order_users
          FROM `project.dataset.users_table` AS users
          JOIN (
          SELECT user_id, MIN(order_date) first_order_date
          FROM `project.dataset.orders_table`
          GROUP BY user_id
          ) AS orders
          ON users.id = orders.user_id
          WHERE DATE_DIFF(first_order_date, registration_date, DAY) = 1





          share|improve this answer























          • Makes sense, thank you

            – Vadim Tikanov
            Mar 26 at 21:49















          1














          Below is for BigQuery Standard SQL



          #standardSQL
          SELECT COUNT(1) next_day_order_users
          FROM `project.dataset.users_table` AS users
          JOIN (
          SELECT user_id, MIN(order_date) first_order_date
          FROM `project.dataset.orders_table`
          GROUP BY user_id
          ) AS orders
          ON users.id = orders.user_id
          WHERE DATE_DIFF(first_order_date, registration_date, DAY) = 1





          share|improve this answer























          • Makes sense, thank you

            – Vadim Tikanov
            Mar 26 at 21:49













          1












          1








          1







          Below is for BigQuery Standard SQL



          #standardSQL
          SELECT COUNT(1) next_day_order_users
          FROM `project.dataset.users_table` AS users
          JOIN (
          SELECT user_id, MIN(order_date) first_order_date
          FROM `project.dataset.orders_table`
          GROUP BY user_id
          ) AS orders
          ON users.id = orders.user_id
          WHERE DATE_DIFF(first_order_date, registration_date, DAY) = 1





          share|improve this answer













          Below is for BigQuery Standard SQL



          #standardSQL
          SELECT COUNT(1) next_day_order_users
          FROM `project.dataset.users_table` AS users
          JOIN (
          SELECT user_id, MIN(order_date) first_order_date
          FROM `project.dataset.orders_table`
          GROUP BY user_id
          ) AS orders
          ON users.id = orders.user_id
          WHERE DATE_DIFF(first_order_date, registration_date, DAY) = 1






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 17:42









          Mikhail BerlyantMikhail Berlyant

          68.6k4 gold badges43 silver badges82 bronze badges




          68.6k4 gold badges43 silver badges82 bronze badges












          • Makes sense, thank you

            – Vadim Tikanov
            Mar 26 at 21:49

















          • Makes sense, thank you

            – Vadim Tikanov
            Mar 26 at 21:49
















          Makes sense, thank you

          – Vadim Tikanov
          Mar 26 at 21:49





          Makes sense, thank you

          – Vadim Tikanov
          Mar 26 at 21:49













          2














          Just put your query into subquery. You are already choosing clients who ordered next day after registration. So answer is a number of rows in your query



          select count(1)
          from ( SELECT
          users.first_name as first_name,
          users.last_name as last_name,
          users.registration_date as registration_date,
          min(orders.order_date) as first_order_date
          FROM `users_table` as users
          JOIN `orders_table` as orders
          ON users.id = orders.user_id
          GROUP BY
          first_name,
          last_name,
          registration_date
          HAVING
          date_diff(first_order_date, registration_date, DAY) = 1 ) x





          share|improve this answer























          • That worked, thank you. Are nested SELECTs a common practice? Or there might be more elegant solution here?

            – Vadim Tikanov
            Mar 25 at 14:56












          • It's very common practice. Of course there are different solutions to your problem, one of them is nested table

            – lypskee
            Mar 25 at 15:04















          2














          Just put your query into subquery. You are already choosing clients who ordered next day after registration. So answer is a number of rows in your query



          select count(1)
          from ( SELECT
          users.first_name as first_name,
          users.last_name as last_name,
          users.registration_date as registration_date,
          min(orders.order_date) as first_order_date
          FROM `users_table` as users
          JOIN `orders_table` as orders
          ON users.id = orders.user_id
          GROUP BY
          first_name,
          last_name,
          registration_date
          HAVING
          date_diff(first_order_date, registration_date, DAY) = 1 ) x





          share|improve this answer























          • That worked, thank you. Are nested SELECTs a common practice? Or there might be more elegant solution here?

            – Vadim Tikanov
            Mar 25 at 14:56












          • It's very common practice. Of course there are different solutions to your problem, one of them is nested table

            – lypskee
            Mar 25 at 15:04













          2












          2








          2







          Just put your query into subquery. You are already choosing clients who ordered next day after registration. So answer is a number of rows in your query



          select count(1)
          from ( SELECT
          users.first_name as first_name,
          users.last_name as last_name,
          users.registration_date as registration_date,
          min(orders.order_date) as first_order_date
          FROM `users_table` as users
          JOIN `orders_table` as orders
          ON users.id = orders.user_id
          GROUP BY
          first_name,
          last_name,
          registration_date
          HAVING
          date_diff(first_order_date, registration_date, DAY) = 1 ) x





          share|improve this answer













          Just put your query into subquery. You are already choosing clients who ordered next day after registration. So answer is a number of rows in your query



          select count(1)
          from ( SELECT
          users.first_name as first_name,
          users.last_name as last_name,
          users.registration_date as registration_date,
          min(orders.order_date) as first_order_date
          FROM `users_table` as users
          JOIN `orders_table` as orders
          ON users.id = orders.user_id
          GROUP BY
          first_name,
          last_name,
          registration_date
          HAVING
          date_diff(first_order_date, registration_date, DAY) = 1 ) x






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 14:46









          lypskeelypskee

          1517 bronze badges




          1517 bronze badges












          • That worked, thank you. Are nested SELECTs a common practice? Or there might be more elegant solution here?

            – Vadim Tikanov
            Mar 25 at 14:56












          • It's very common practice. Of course there are different solutions to your problem, one of them is nested table

            – lypskee
            Mar 25 at 15:04

















          • That worked, thank you. Are nested SELECTs a common practice? Or there might be more elegant solution here?

            – Vadim Tikanov
            Mar 25 at 14:56












          • It's very common practice. Of course there are different solutions to your problem, one of them is nested table

            – lypskee
            Mar 25 at 15:04
















          That worked, thank you. Are nested SELECTs a common practice? Or there might be more elegant solution here?

          – Vadim Tikanov
          Mar 25 at 14:56






          That worked, thank you. Are nested SELECTs a common practice? Or there might be more elegant solution here?

          – Vadim Tikanov
          Mar 25 at 14:56














          It's very common practice. Of course there are different solutions to your problem, one of them is nested table

          – lypskee
          Mar 25 at 15:04





          It's very common practice. Of course there are different solutions to your problem, one of them is nested table

          – lypskee
          Mar 25 at 15:04











          0














          Why not just use a JOIN condition?



          SELECT COUNT(DISTINCT u.id)
          FROM `users_table` u JOIN
          `orders_table` o
          ON u.id = o.user_id AND
          date_diff(o.order_date, u.registration_date, DAY) = 1;


          The COUNT(DISTINCT accounts for the fact that users could have multiple orders in one day.






          share|improve this answer























          • User's got several orders with different dates. I need the date of first order for comparison. When trying "date_diff(min(orders.order_date), users.registration_date, DAY)" I receive "Aggregate function MIN not allowed in JOIN ON clause".

            – Vadim Tikanov
            Mar 25 at 15:12











          • Is it possible for a user to make an order before that date?

            – Gordon Linoff
            Mar 25 at 15:22











          • There are several orders per user. E.g. user had registered on November 1st and made 3 orders on November 2nd, November 5th and November 21st. I need to count ones, who made their first order right on the next day after registration. They can't make orders before registration.

            – Vadim Tikanov
            Mar 25 at 15:27
















          0














          Why not just use a JOIN condition?



          SELECT COUNT(DISTINCT u.id)
          FROM `users_table` u JOIN
          `orders_table` o
          ON u.id = o.user_id AND
          date_diff(o.order_date, u.registration_date, DAY) = 1;


          The COUNT(DISTINCT accounts for the fact that users could have multiple orders in one day.






          share|improve this answer























          • User's got several orders with different dates. I need the date of first order for comparison. When trying "date_diff(min(orders.order_date), users.registration_date, DAY)" I receive "Aggregate function MIN not allowed in JOIN ON clause".

            – Vadim Tikanov
            Mar 25 at 15:12











          • Is it possible for a user to make an order before that date?

            – Gordon Linoff
            Mar 25 at 15:22











          • There are several orders per user. E.g. user had registered on November 1st and made 3 orders on November 2nd, November 5th and November 21st. I need to count ones, who made their first order right on the next day after registration. They can't make orders before registration.

            – Vadim Tikanov
            Mar 25 at 15:27














          0












          0








          0







          Why not just use a JOIN condition?



          SELECT COUNT(DISTINCT u.id)
          FROM `users_table` u JOIN
          `orders_table` o
          ON u.id = o.user_id AND
          date_diff(o.order_date, u.registration_date, DAY) = 1;


          The COUNT(DISTINCT accounts for the fact that users could have multiple orders in one day.






          share|improve this answer













          Why not just use a JOIN condition?



          SELECT COUNT(DISTINCT u.id)
          FROM `users_table` u JOIN
          `orders_table` o
          ON u.id = o.user_id AND
          date_diff(o.order_date, u.registration_date, DAY) = 1;


          The COUNT(DISTINCT accounts for the fact that users could have multiple orders in one day.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 14:58









          Gordon LinoffGordon Linoff

          826k38 gold badges337 silver badges443 bronze badges




          826k38 gold badges337 silver badges443 bronze badges












          • User's got several orders with different dates. I need the date of first order for comparison. When trying "date_diff(min(orders.order_date), users.registration_date, DAY)" I receive "Aggregate function MIN not allowed in JOIN ON clause".

            – Vadim Tikanov
            Mar 25 at 15:12











          • Is it possible for a user to make an order before that date?

            – Gordon Linoff
            Mar 25 at 15:22











          • There are several orders per user. E.g. user had registered on November 1st and made 3 orders on November 2nd, November 5th and November 21st. I need to count ones, who made their first order right on the next day after registration. They can't make orders before registration.

            – Vadim Tikanov
            Mar 25 at 15:27


















          • User's got several orders with different dates. I need the date of first order for comparison. When trying "date_diff(min(orders.order_date), users.registration_date, DAY)" I receive "Aggregate function MIN not allowed in JOIN ON clause".

            – Vadim Tikanov
            Mar 25 at 15:12











          • Is it possible for a user to make an order before that date?

            – Gordon Linoff
            Mar 25 at 15:22











          • There are several orders per user. E.g. user had registered on November 1st and made 3 orders on November 2nd, November 5th and November 21st. I need to count ones, who made their first order right on the next day after registration. They can't make orders before registration.

            – Vadim Tikanov
            Mar 25 at 15:27

















          User's got several orders with different dates. I need the date of first order for comparison. When trying "date_diff(min(orders.order_date), users.registration_date, DAY)" I receive "Aggregate function MIN not allowed in JOIN ON clause".

          – Vadim Tikanov
          Mar 25 at 15:12





          User's got several orders with different dates. I need the date of first order for comparison. When trying "date_diff(min(orders.order_date), users.registration_date, DAY)" I receive "Aggregate function MIN not allowed in JOIN ON clause".

          – Vadim Tikanov
          Mar 25 at 15:12













          Is it possible for a user to make an order before that date?

          – Gordon Linoff
          Mar 25 at 15:22





          Is it possible for a user to make an order before that date?

          – Gordon Linoff
          Mar 25 at 15:22













          There are several orders per user. E.g. user had registered on November 1st and made 3 orders on November 2nd, November 5th and November 21st. I need to count ones, who made their first order right on the next day after registration. They can't make orders before registration.

          – Vadim Tikanov
          Mar 25 at 15:27






          There are several orders per user. E.g. user had registered on November 1st and made 3 orders on November 2nd, November 5th and November 21st. I need to count ones, who made their first order right on the next day after registration. They can't make orders before registration.

          – Vadim Tikanov
          Mar 25 at 15:27


















          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%2f55340323%2fchanging-query-to-avoid-aggregations-of-aggregations-are-not-allowed-in-bigque%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

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해