mavmanau
asked on
ODBC SQL issue - SUM or SUMIF
ODBC SQL Query question
Hi,
We have recently upgraded some of our systems, and have changed our connectivity that some of our pages use to reach into our DB.
I have had to rewrite some of our SQL query's to suit. We are now using an ODBC connection that talks to an SQL server in php 5.6.
the below query works:
Select dbo.client.cl_number, dbo.debtor.de_type, dbo.debtor.de_listed_date, dbo.de_transaction.tr_post ed_date, sum(CASE when dbo.de_transaction.tr_acco unt='16' then (dbo.de_transaction.tr_to_ agency+dbo .de_transa ction.tr_t o_client)* -1 ELSE 0) FROM dbo.de_transaction LEFT JOIN dbo.debtor on dbo.de_transaction.tr_rowi d_debtor = dbo.debtor.de_rowid JOIN dbo.client on dbo.client.cl_rowid = dbo.debtor.de_rowid_client where dbo.client.cl_number > '110' and dbo.client.cl_number < '119' group By dbo.debtor.de_listed_date, dbo.client .cl_number ,dbo.debto r.de_type, dbo.de_tra nsaction.t r_posted_d ate
apart from this part:
sum(CASE when dbo.de_transaction.tr_acco unt='16' then (dbo.de_transaction.tr_to_ agency+dbo .de_transa ction.tr_t o_client)* -1 ELSE 0)
could you please help me?
The basics of it are this: if de_transaction.tr_account = 16 then I want it to add up de_transaction.tr_to_agenc y and de_transaction.tr_to_clien t and then multiply it by -1 otherwise it equals 0.
Hi,
We have recently upgraded some of our systems, and have changed our connectivity that some of our pages use to reach into our DB.
I have had to rewrite some of our SQL query's to suit. We are now using an ODBC connection that talks to an SQL server in php 5.6.
the below query works:
Select dbo.client.cl_number, dbo.debtor.de_type, dbo.debtor.de_listed_date,
apart from this part:
sum(CASE when dbo.de_transaction.tr_acco
could you please help me?
The basics of it are this: if de_transaction.tr_account = 16 then I want it to add up de_transaction.tr_to_agenc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A pleasure, and easy enough to do, we all have - at some point in time - even multiple times :)
Many eyes makes light work - and that is what we are here for :)
Cheers,
Mark Wills
Many eyes makes light work - and that is what we are here for :)
Cheers,
Mark Wills
ASKER