Help with Query --- Returning All Rows and Value x IF exist

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

Help with Query --- Returning All Rows and Value x IF exist

Postby cjonestx » 03. October 2008 16:38

Need Help! Trying to determine how can I return all rows and IF chargetypeid '19' exist ALSO display that value but no other chargetypes? Currently it's returning all '19' chargetypes and ALL '0' but if I put "= chargetypeid = '19' it only returns data that has that value in it.

Query:

select distinct
a.accountnum,
a.cycleid,
a.usagecharges,
a.totalcurrentcharges,
b.chargeamount,
case when b.chargeTypeId=19 then '19' else '0' END as chargeType
from
invoice.invoice a
left join invoice.invoice_charges b on b.invoiceid=a.invoiceid
where
a.cycleid IN ('388','398')
and
a.revenuestream = '50'
and
order by accountnum, chargeType desc, cycleid;
cjonestx
 
Posts: 1
Joined: 03. October 2008 16:33

Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 8 guests