Ben almak istiyorum bir sorgu var:
Username
mevcut fırsat kaydına bağlı kullanıcınınSales Stage
, her fırsat kaydı ile ilişkiliFırsat kaydı ile ilişkili
Dollar
tutarı
Ben istiyorum:
- Akım IF TABLOSU sonuç almak ve daraltmak
Şu Sorgu:
$sql = "SELECT u.user_name as USER,
if(o.sales_stage='Prospecting', o.amount, '') as PROSPECTING,
if(o.sales_stage='Needs Analysis', o.amount, '') as NEEDS_ANALYSIS,
if(o.sales_stage='Closed Won', o.amount, '') as CLOSED_WON
FROM opportunities o,
users u
WHERE o.assigned_user_id = u.id
GROUP BY u.user_name ";
Şu Sonuç:
USER PROSPECTING NEEDS_ANALYSIS CLOSED_WON
---------------------------------------------
chris 10000 0 0
chris 0 15000 0
chris 0 0 10000
sara 5000 0 0
sara 0 0 10000
What I'd like to do is collapse the results where I only get 1 user, and their respective amounts per SalesStage
USER PROSPECTING NEEDS_ANALYSIS CLOSED_WON
---------------------------------------------
chris 10000 15000 10000
sara 5000 0 10000