Solved

how to use parameters in SQL Expression field

Posted on 2007-03-27
7
390 Views
Last Modified: 2012-06-27
Hi Experts,

 I have a Crystal report which need to summarize value from another table using paramters entered by user and the value can only sum in a sql exprssion field. But Sql expression can not reach the parameters. e.g
(select sum(price) from InvoiceSum where Invoicedate  beteen {?sDate} and {?eDate})

Please help.

Cw

0
Comment
Question by:lanac222
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 23

Accepted Solution

by:
Ido Millet earned 125 total points
ID: 18800560
I don't know how this can be done in Crystal.  However, at least one 3rd-party UFL (see list at: http://www.kenhamady.com/bookmarks.html) allows you to use a Crystal formula to construct and return the result of an SQL statement.  That approach makes it easy to embed the parameter value inside the SQL statement.
0
 
LVL 26

Assisted Solution

by:Kurt Reinhardt
Kurt Reinhardt earned 125 total points
ID: 18800569
Unfortunately, you've run into a limitation of SQL Expression fields.  Since they're evaluated and passed to the database prior to formulas and parameters, they can't use either of those types of fields.  They can only refer to true database fields.

For your situation, however, ss the data in the other table related to the data in the main report?  If so, you could limit the data in the main report by the parameters within your record selection criteria.  Then, if you relate the data in the main report to the data in the other table through the SQL Expression you should only get records that are within the data range specified.  As an example:

//Record Selection Criteria
{table.field} in {?sDate} to {?eDate"

//SQL Expression
(
SELECT
  SUM(field)
FROM
  table
WHERE
  field = "mainreporttable"."mainreportfield"
)

Unfortunately, if the data in the other table is completely unrelated AND you need to parameterize the data selection, then you might need to use a subreport.

~Kurt
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 18800607
0
 

Author Comment

by:lanac222
ID: 18800787
Thanks experts. I tried to use subreport. But can not make link to the subreport. Main report table date field doesn't match the date field in subreport table.

Eg. main report show user login to system multi times a day. Each day user may have vary number of transactions. How can summarize transaction amount in subreport by the date range in main report?

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 18801917
WHat are the date fields in each report?

mlmcc
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question