Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Select Expert Vs SQL Post Reply Post New Topic
Author Message
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Topic: Select Expert Vs SQL
    Posted: 28 Apr 2007 at 3:46pm
Hi:
 
My SQL doesn't have order date = 2004 in my where clause but it exists in select expert. Does any one know why.?
 
Thanks
Vijay
 
select expert looks like
 
{Customer.Region} in ["BC", "CA"] and
{Orders.Order Amount} > $1000.00 and
Year({Orders.Order Date}) = 2004
 
SQL looks like
 
 SELECT `Customer`.`Customer Name`, `Customer`.`City`, `Customer`.`Region`, `Orders`.`Order Amount`, `Orders`.`Order ID`, `Orders`.`Order Date`
 FROM   `Customer` `Customer` INNER JOIN `Orders` `Orders` ON `Customer`.`Customer ID`=`Orders`.`Customer ID`
 WHERE  (`Customer`.`Region`='BC' OR `Customer`.`Region`='CA') AND `Orders`.`Order Amount`>1000

 
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 30 Apr 2007 at 11:37am
Crystal Reports doesn't convert EVERY function into SQL for the select statement. It only does it when it knows that there is a simple conversion for the SQL equivalent. However, I would have thought that the Year() function would be easy enough to replicate in SQL. One option would be to create a SQL function and then use that function in your selection formula. That ensures that CR will pass it down to the database level.
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
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Posted: 11 May 2007 at 12:17pm
Thanks Brian.. I am confused in the sense some conditions in the select expert are only reflected in the SQL and some aren't. I am assuming formula fields are always applied at the report level and SQL expression fields are always applied at the database level.
 
Thanks
Vijay
 
 
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 11 May 2007 at 2:48pm
Crystal has a list of guidelines it uses when deciding which functions to convert to SQL and which to do at the report level. Yes, formula fields are always applied at the report level and SQL expression fields are passed directly to the database.
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
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Posted: 14 May 2007 at 2:21pm
Thanks..!
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.