MySQL Forums
Forum List  »  Newbie

SubQuery same table
Posted by: T Jor
Date: January 04, 2020 08:59AM

Hi,
I have a table with these field:

Table: wp_contacts_submits

wp_contactic_submits.form_name;
wp_contactic_submits.field_name,
wp_contactic_submits.Image,
wp_contactic_submits.field_value,


running sql / working fine
SELECT DISTINCT wp_contactic_submits.field_name, wp_contactic_submits.Image, wp_contactic_submits.form_name, Sum(wp_contactic_submits.field_value) AS SUM
FROM `wp_contactic_submits`
WHERE field_name IN('Oliver','Jeppe') and form_name IN('Barcelona','Liverpool') GROUP BY wp_contactic_submits.field_name


Result:
Field_name / image / form_name / SUM
Oliver / photo1 / Barcelona / 38
Jeppe / photo2 /Barcelona / 40
Oliver / photo1 / Liverpool / 20
Jeppe / photo2 /Liverpool / 17



Instead I will like to have a output like:

Field_name / image / Barcelona / Liverpool / total sum
Oliver / photo1 / 38 / 20 / 58
Jeppe /Photo2 / 40 / 17 / 57

Anybody can help me :-) ?
Thanks
BR Thomas

Options: ReplyQuote


Subject
Written By
Posted
SubQuery same table
January 04, 2020 08:59AM
January 04, 2020 10:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.