Viewing a response to: @penderis/foooking-can-t-grok-groupby
author | tierra-errante |
---|---|
permlink | re-penderis-2024315t111938715z |
category | postgres |
json_metadata | {"type":"comment","tags":["postgres","coding","database","sql","webdevelopment","proofofbrain","hive-engine"],"app":"ecency/3.0.46-mobile","format":"markdown+html"} |
created | 2024-03-15 15:19:39 |
last_update | 2024-03-15 15:19:39 |
depth | 1 |
children | 3 |
last_payout | 2024-03-22 15:19:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.012 HBD |
curator_payout_value | 0.012 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 22 |
author_reputation | 8,138,916,505,133 |
root_title | "Foooking can't grok GroupBy in Postgres" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 132,074,171 |
net_rshares | 54,176,903,325 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
penderis | 0 | 37,689,999,085 | 100% | ||
dustbunny | 0 | 16,486,904,240 | 4.78% |
Yup, Eloquent from Laravel which I think is the part that kinda made me insist it can be done the way I want. Since there is the groupBy method for the ORM but also groupBy for result object. The groupBy on the result object does exactly what I showed and keys the results accordingly, where as the groupBy on the ORM or query builder is an interface for the SQL engines methods and in POSTGRES you have to have all columns from the select available in the groupBy + then any aggregates you use can be excluded so counting etc works but if I wanted all the data the best is to use the result and instead groupBy in my code to build the structure I want.
author | penderis |
---|---|
permlink | re-tierra-errante-2024315t1739161z |
category | postgres |
json_metadata | {"tags":["postgres","coding","database","sql","webdevelopment","proofofbrain","hive-engine"],"app":"ecency/3.1.0-vision","format":"markdown+html"} |
created | 2024-03-15 15:39:21 |
last_update | 2024-03-15 15:39:21 |
depth | 2 |
children | 2 |
last_payout | 2024-03-22 15:39:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.012 HBD |
curator_payout_value | 0.012 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 654 |
author_reputation | 153,012,169,855,556 |
root_title | "Foooking can't grok GroupBy in Postgres" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 132,074,546 |
net_rshares | 54,166,265,181 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
dustbunny | 0 | 52,673,439,947 | 15.24% | ||
tierra-errante | 0 | 1,492,825,234 | 100% |
I think I understand, it just seems ugly to re-execute one query after another to recover the missing data
author | tierra-errante |
---|---|
permlink | re-penderis-2024315t153247913z |
category | postgres |
json_metadata | {"tags":["postgres","coding","database","sql","webdevelopment","proofofbrain","hive-engine"],"app":"ecency/3.1.0-vision","format":"markdown+html"} |
created | 2024-03-15 19:32:48 |
last_update | 2024-03-15 19:32:48 |
depth | 3 |
children | 1 |
last_payout | 2024-03-22 19:32:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 106 |
author_reputation | 8,138,916,505,133 |
root_title | "Foooking can't grok GroupBy in Postgres" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 132,079,093 |
net_rshares | 0 |
Yes which is why I was pretty determined to get it in one go but for this case specifically I did not really need the extra data. If I did I think I would query the rows as normal and instead of having sql do the computing just run a loop to structure it as I want it , which is actually what I usually do. Guess it depends what I am querying, I will learn better ways to do it as I go I am sure :) !PIZZA
author | penderis |
---|---|
permlink | re-tierra-errante-2024315t2224283z |
category | postgres |
json_metadata | {"tags":["postgres","coding","database","sql","webdevelopment","proofofbrain","hive-engine"],"app":"ecency/3.1.0-vision","format":"markdown+html"} |
created | 2024-03-15 20:02:09 |
last_update | 2024-03-15 20:02:09 |
depth | 4 |
children | 0 |
last_payout | 2024-03-22 20:02:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.012 HBD |
curator_payout_value | 0.013 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 405 |
author_reputation | 153,012,169,855,556 |
root_title | "Foooking can't grok GroupBy in Postgres" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 132,079,569 |
net_rshares | 55,221,402,272 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
dustbunny | 0 | 52,741,797,516 | 15.26% | ||
tierra-errante | 0 | 2,479,604,756 | 100% |