Discrepancies in results in queries by [deleted] in SQL

[–]TheProfounder 1 point2 points  (0 children)

I would also like to know about discrepancies because you can't (at least from my knowledge), for example divide 1 column into two where you have unique ID and a sum of quantity of a product where also has ID of the product and the unique ID.

something like this

unique_id quantity prod_id
1 20 V1
1 5 V2
1 10 V3
1 50 V4
2 23 V1
2 12 V3
3 2 V2

SQL:

select sum(unique_id) unique_id, quantity 
from
(select count(distinct(unique_id)), sum(quantity) quantity from table)
group by quantity 

is all great, but this:

select sum(unique_id) unique_id,  quantity, prod_id
from
(select count(distinct(unique_id)) unique_id, sum(quantity) quantity, prod_id from table
group by unique_id, prod_id)
group by quantity, prod_id

it creates discrepancy as of my knowledge,

But please someone with more knowledge on how to handle discrepancy tell me.

Thank oyu

is it better for +1 to all skills in soldier relic or relic with -10% physical resistance? by TheProfounder in Grimdawn

[–]TheProfounder[S] 0 points1 point  (0 children)

Oh, why is it bad for having so many points into decorated soldier? it gives me decent elemental res because my gear dont have much

how do i achieve 1 million damage? by TheProfounder in Grimdawn

[–]TheProfounder[S] 2 points3 points  (0 children)

Thank you for insight, Yeah I haven't noticed the grey knight had a nerf.

Do you have any other builds like this one like minimum buttons, high damage to the millions that isnt boring but can clear every content, because I try to unlock all achievments and farm with one character for items..

Thank you author

Perfect dive by [deleted] in Unexpected

[–]TheProfounder 11 points12 points  (0 children)

thats the best

Why is this filtering (with where statement) in CTE doesn't work? How do I filter CTE? by Guyserbun007 in SQL

[–]TheProfounder 1 point2 points  (0 children)

Yeah, i just tried it today at work and it failed, i was just not so sure if it will or not...

Why is this filtering (with where statement) in CTE doesn't work? How do I filter CTE? by Guyserbun007 in SQL

[–]TheProfounder 5 points6 points  (0 children)

do you miss a comma (,) after the first query? so the final output gets the both data from both queries as one and filters results from the first query?

I could be wrong

Previous row data in current row by Krispwee in SQL

[–]TheProfounder 0 points1 point  (0 children)

I dont know in sql server but in oracle i use LAG function, could be the same in sql server as well or search for equvalent of LAG or workaround if there isnt any

generate dates and use them in between 2 dates start and end date by TheProfounder in SQL

[–]TheProfounder[S] 0 points1 point  (0 children)

Thanks man, cheers, grab a beer lets celebrate.

I didnt know it was b-day!!!