Click here to Skip to main content
15,860,943 members

Comments by Member 14173753 (Top 7 by date)

Member 14173753 8-Mar-19 5:24am View    
I use below quey, it final return 91 record (it's ok), but in form if user choose some condition as the date from x to y, and name is Jack... I can't apply fillter to MAIN WHERE, as:

query += " AND (R.TheDate between @fromdate and @todate) AND (P.TheDate between @fromdate and @todate) ";

query += " AND C.Name LIKE '%' + @TheName + '%'";

if user choose date then ERROR: Invalid colum name thedate


THIS IS MY QUERY:

Query= "select c.name,
case when
isnull(p.pmoney,0) - ISNULL(r.rmoney,0)>0
then isnull(p.pmoney,0) - ISNULL(r.rmoney,0)
else null end
debitBanance,
case when
ISNULL(r.rmoney,0)-isnull(p.pmoney,0) >0
then ISNULL(r.rmoney,0)-isnull(p.pmoney,0)
else null end incredit

from
customer c left join
(select sum(money) rmoney,id_customer from receipt group by id_customer ) as r
on c.id_customer=r.id_customer
left join
(select sum(money) pmoney, id_customer from payment group by id_customer) as p
on c.id_customer=p.id_customer
where r.rmoney is not null or p.pmoney is not null" //here I Add to where clause
Member 14173753 8-Mar-19 2:44am View    
CHIII60, I posted my query below, but it running very slow. if you have time, please me!
Member 14173753 7-Mar-19 5:19am View    
Thanks CHiLl60 vere very much, I will check and please notice to you.

Thanks you.
Member 14173753 7-Mar-19 4:02am View    
Thanks you CHil60 very Much, and I'm sorry when say urgent. I hope that you can help me. again thanks for. I waiting you.
Member 14173753 7-Mar-19 3:43am View    
anybody can help me!