September 25, 2007 at 5:08 am
Hi All,
I have 4 tables customermaster,usermaster,leadsmaster
theres a col cAccStatus(old,New) in Customermaster.
I want to get total sales by a user of old and new accounts like
UserName,RevenueOld,RevenueNew
Revenue is in leadsmaster
iam using following qry
select susername,sum(lps.iqty*lps.cprice) as 'Revenue',cAccStatus from usermaster u
inner join leadsmaster l on u.iuserid=l.iuserid
inner join leadproddetails lps on l.ileadid=lps.ileadid
inner join customermaster c on l.icustomerid=c.icustomerid
where ileadstatus=3 and dtclosuredate between '2007-09-01' and '2007-09-27'
and (cAccstatus='New'or cAccstatus='OLD')
group by cAccstatus,susername with rollup
Regards,
[font="Verdana"]Sqlfrenzy[/font]
September 25, 2007 at 6:43 am
Ahmad -
I can't tell what the actual question/issue is. There simply isn't enough info to tell. Are you looking to have the values on the same line? It would also be important to give some more specifics on table structure so that we can help you with that...
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
September 25, 2007 at 8:37 am
I agree with Matt. You haven't provided enough information. Also it doesn't seem like you need the customer table in your query. Be sure you only join in tables that return columns or are needed for the joins. Easy to forget this and add extra tables because you're used to having them for other queries.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply