on 10-06-2009 11:10 PM
Hello,
I'm have a report which joins three tables based on criteria passed in. One of the parameters is included in a WHERE clause to identify records in a specific date range. Crystal Report automatically adds the fields in the WHERE clause to my SELECT, causing duplicates to appear in the recordset. Is this expected? Is thre anyway around this?
I don't use the date field in the report at all, just in the SQL. I already tried the DISTINCT option. It removed some records but not all. Any suggestions would be greatly, greatly, appreciated!
"automatically adds the fields in the WHERE clause to my SELECT"????
Post your SQL query
Jyothi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
Thanks for reply. I want to do something like the following:
SELECT DISTINCT NAME, ADDRESS FROM EMPLOYEE WHERE HIRE_DATE >= '20090101'
However, if I check the SQL query (Database -> Show SQL Query...) I get the following:
SELECT DISTINCT NAME, ADDRESS, HIRE_DATE FROM EMPLOYEE WHERE HIRE_DATE >= '20090101'
The hire date is automatically included in the SELECT statement, even though I only want the NAME and ADDRESS fields.
If you add table to report, Crystal will have all the fields from the table. where did you add "Where Clause", if you used table directly.
Whats the problem with parameters? If Hire date is a datetime type , you parameter should also be of same type and same format.
Its always better to use SQL command to tables.
Jyothi
I used the SELECT expert to define the WHERE clause.
I don't see the logic behind adding all the fields from the WHERE clause into the SELECT. Now I can't even use a GROUP BY to filter out the duplicates. Might be an issue with design, but I would think we could get around it by just removing the field in the WHERE clause from the SELECT portion of the statement.
As for the parameters, I tried to use a function ToText(, "yyyyMMdd") in the command SQL, but it didn't work.
Its a feature of crystal to add fields in SQL query..below is the description for SHOW SQL Query dialog.
"SELECT lists fields used in the report, including those in formulas, totals, sort, selection and ranges. FROM lists tables in the report followed by aliases. WHERE specifies field ranges and link between tables. ORDER BY is sort order"
you can't use totext in SQL command, but you can in select expert
Whats your database? whats the format of hire_date
Jyothi
I'm using an Oracle database.
I think you've helped me see a different approach, if I use a SQL command, I should be able to use Oracle functions to format the date parameter instead of using the Crystal functions right?
Hmm... This may be it... Thanks!
However, still don't understanding the reasoning to why the developers opted to automatically add the fields in the WHERE to the SELECT.
Hi,
Yes command is a better approach for records.
I think answer to your question why date field is being displayed in query is that--in reports we use select expert to display records like where clause e.g. in ur case where date field> value.
But for this,we have to select that field then only we can say field selected satisfies this condition(like < ,>, = ,between).
I think that is the reason.
Regards,
Misra P.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.