การค่าผมรวม โดย SUM() และภายในข้อมูลนั้นมีค่าที่ซ้ำด้วยค่ะ

เริ่มโดย test_one, 17 ตุลาคม 2015, 00:27:46

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

test_one

การค่าผมรวม โดย SUM() และภายในข้อมูลนั้นมีค่าที่ซ้ำด้วยค่ะ

rebook_id | customer_id | even_id | grp_id
1 | 2 | 2 | 2
2 | 2 | 2 | 3
3 | 3 | 2 | 4


select sum(v_customer.customer_amount)
from v_customer inner join v_rebook On(v_customer.customer_id = v_rebook.customer_id)
inner join v_grp On(v_rebook.grp_id = v_grp.grp_id)
inner join v_event On(v_customer.event_id = v_event.event_id)
where v_customer.customer_date like '2015-09-08%'
and v_customer.event_id = '1'
and v_customer.customer_status = 'Y'



ทำยังไงค่าที่ได้มา customer_id จะไม่ซ้ำ ค่ะ รบกวนหน่อยนะค่ะ

Nokky@#

https://www.trcloud.org
[direct= *Link Removed* ]โปรแกรมบัญชีออนไลน์[/direct]

nattapol196

ถ้าเข้าใจไม่ผิดกับคำถามนะครับ

เพิ่ม group by v_customer.customer_id ต่อท้ายเข้าไปด้วยครับ