Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: SQL Post Reply Post New Topic
Author Message
ckreds
Newbie
Newbie


Joined: 24 Sep 2007
Location: Malaysia
Online Status: Offline
Posts: 16
Quote ckreds Replybullet Topic: SQL
    Posted: 02 Dec 2007 at 11:16pm
i have created a report which joining 3 tables and created 3 grouping. Could i export this SQL from the crystal report?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 02 Dec 2007 at 11:19pm
Do you mean you want to be able to copy and paste the SQL that Crystal created? Yes, you can do that. Click on Database > Show SQL Query and then copy and paste it.
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
ckreds
Newbie
Newbie


Joined: 24 Sep 2007
Location: Malaysia
Online Status: Offline
Posts: 16
Quote ckreds Replybullet Posted: 03 Dec 2007 at 5:51pm
Ya. i want to copy and paste it. i tried the method you have mentioned but the "Show SQL Query" only displays 3 separated Select statement for each table. It doesnt display the linking between table and grouping is also not included. Thks
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 04 Dec 2007 at 10:49am
That would be because the linking and grouping isn't done with SQL.  However, generally speaking, it isn't hard to reproduce.

Take the SQL in the Show SQL Query result.
Take all the SELECT statements and concatenate them into one big SELECT statement.
Put the first FROM statement as your FROM statement.
Type "JOIN" and put your second FROM statement (with the "FROM", obviously).  If it's an outer join, put either "LEFT" or "RIGHT" in front of the "JOIN."
Type "ON" and put the link field(s).  This should look something like:
"ON Table1.KeyField = Table2.KeyField".
Repeat for your third FROM statement.
Concatenate your WHERE clauses.  Make note of any that might affect outer joins.
After your WHERE clauses, type "GROUP BY" and the fields you want to group by, in the order they appear in the group expert.
If you have any sorting, that goes in an "ORDER BY" clause at the end.


IP IP Logged
ckreds
Newbie
Newbie


Joined: 24 Sep 2007
Location: Malaysia
Online Status: Offline
Posts: 16
Quote ckreds Replybullet Posted: 04 Dec 2007 at 5:47pm
noted..thks a lot..
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.047 seconds.