Answer the question
In order to leave comments, you need to log in
Query with counting values from two columns (mysql)
in the product_id column, you need to count the number of duplicate values
in the notified column, you need to get the sum of all values \u200b\u200brelated to your value in the product_id column
For example:
product_id = 19 there are 3 values
notified (for product_id = 19) sum = 2
As a result, I need to add the values 3 and 2 I 'm
trying this way
SELECT COUNT(*) + SUM(nwa.notified) FROM notify_when_arrives nwa GROUP BY nwa.product_id
but it doesn't turn out to be what I need ...
help me make a request
Answer the question
In order to leave comments, you need to log in
As far as I understand, this is how it should work.
SELECT nwa.product_id, (COUNT(*) + SUM(nwa.notified)) AS itog FROM notify_when_arrives nwa GROUP BY nwa.product_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question