Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Passing Parameter in Subquery of Command Post Reply Post New Topic
Author Message
Ghauri
Newbie
Newbie
Avatar

Joined: 27 Nov 2007
Location: Pakistan
Online Status: Offline
Posts: 13
Quote Ghauri Replybullet Topic: Passing Parameter in Subquery of Command
     Posted: 02 Jun 2008 at 4:12am
Hi all,

 I have a report based on command. The command contains a query like below:

 select . . .
  from tablist
  where attribute in (subquery1)
  and
   attribute not in (subquery2)

subquery2 filters data based on input parameters (fromdate and todate),
but the problem is:

Report is not filtering data based on parameters. Why it is so???
If I hard code the values in query then the result is fine.

Please help, its urgent.

Thanks & Regards,
Ghauri
Thanks & Regards,
Ghauri
IP IP Logged
Iago
Groupie
Groupie
Avatar

Joined: 01 Oct 2007
Location: United States
Online Status: Offline
Posts: 52
Quote Iago Replybullet Posted: 02 Jun 2008 at 1:21pm
Stored Procedure in SQL 2000/2005 should do the trick and be fast. 
 
 

Create procedure [dbo].[getDeficitNetWorth]

(

@sub_no int = 80)

as

set nocount on

SELECT Bal.Net_Worth, Bal.acct_no, Bal.sub_no, Bal.datadate, Bal.money_mkt_bal, Bal.mkt_val_amt, Bal.equity_amt, Bal.cash_free_cr, Act.rep,

Act.Account_Name, Bal.long_mkt_value_amt, Bal.trade_dt_bal

FROM vwDailyStatsBalances AS Bal INNER JOIN

vwDIMCurrentAccountInfo AS Act ON Bal.acct_no = Act.acct_no

WHERE (Bal.datadate = dbo.LastWorkDay(GETDATE())) AND (Bal.sub_no = @sub_no) AND (Bal.acct_no NOT IN

(SELECT DISTINCT acct_no

FROM vwPos

WHERE (sub_no = @sub_no) AND (datadate = dbo.LastWorkDay(GETDATE())))) AND (Bal.Net_Worth < 0)

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 02 Jun 2008 at 5:39pm
When pushing down data to the server, make sure to set the option "Use Indexes or Server for Speed" (menu items File >Options, Database tab).
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Ghauri
Newbie
Newbie
Avatar

Joined: 27 Nov 2007
Location: Pakistan
Online Status: Offline
Posts: 13
Quote Ghauri Replybullet Posted: 04 Jun 2008 at 4:47am
Thanks,

    for more clarity. . .
I'm using DB2 and Crystal Report X ( also check in Crystal Report XI).

I have also check that option "Use Indexes or servers for speed"

any other suggestion plzzzzzzzz

Thanks & Regards,
Fahim

Thanks & Regards,
Ghauri
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum