Home > database >  Mysql query problem
Mysql query problem

Time:09-30

A table, field below
Id, shop_Id, member_Id, num

Have the same id and shop_Id uniqueness, member_Id

Now I want to use an SQL statement finds out each of the data and calculate the same total number of num member_id

How can I do?

CodePudding user response:

Now the environment is far better than I give the problem of complex, I simplified the problem, the key question

CodePudding user response:

 
SELECT id, shop_id, member_Id, SUM (num) AS sum_num
FROM the table name
GROUP BY id, shop_id, member_Id

I understand it is a group by ah, not so complicated, I don't know right

CodePudding user response:

refer to the second floor qq_37170555 response:
 
SELECT id, shop_id, member_Id, SUM (num) AS sum_num
FROM the table name
GROUP BY id, shop_id, member_Id

I understand it is a group by ah, not so complicated, I don't know right ha



wrong

CodePudding user response:

reference bleachj88 reply: 3/f
Quote: refer to the second floor qq_37170555 response:

 
SELECT id, shop_id, member_Id, SUM (num) AS sum_num
FROM the table name
GROUP BY id, shop_id, member_Id

I understand it is a group by ah, not so complicated, I don't know right ha



No

You have a wrong, also don't say something wrong, what exactly do you want to what, who can help you

CodePudding user response:

Demand for data

CodePudding user response:

reference 4 floor qq_37170555 response:
Quote: reference bleachj88 reply: 3/f

Quote: refer to the second floor qq_37170555 response:

 
SELECT id, shop_id, member_Id, SUM (num) AS sum_num
FROM the table name
GROUP BY id, shop_id, member_Id

I understand it is a group by ah, not so complicated, I don't know right ha



No

You have a wrong, also don't say something wrong, what exactly do you want to what, who can help you ah


Well,
SELECT a. *, (SELECT sum (num) from table b where Anderson, d=b.i d) sum_num from a table name

CodePudding user response:

reference 4 floor qq_37170555 response:
Quote: reference bleachj88 reply: 3/f

Quote: refer to the second floor qq_37170555 response:

 
SELECT id, shop_id, member_Id, SUM (num) AS sum_num
FROM the table name
GROUP BY id, shop_id, member_Id

I understand it is a group by ah, not so complicated, I don't know right ha



No

You have a wrong, also don't say something wrong, what exactly do you want to what, who can help you ah


Sorry, no clear, this solved, transfer difficulties now...

CodePudding user response:

refer to 7th floor bleachj88 response:
Quote: refer to 4th floor qq_37170555 response:

Quote: refer to the third floor bleachj88 response:

Quote: refer to the second floor qq_37170555 response:

 
SELECT id, shop_id, member_Id, SUM (num) AS sum_num
FROM the table name
GROUP BY id, shop_id, member_Id

I understand it is a group by ah, not so complicated, I don't know right ha



No

You have a wrong, also don't say something wrong, what exactly do you want to what, who can help you ah


Sorry, no clear, this solved, transfer difficulties now...

Shift into what the

CodePudding user response:

The select member_Id sum (num) from the name of the table GROUP BY member_Id; More simple

CodePudding user response:

Both Please list out the data to shou your exact requirement
  • Related