?
Solved

What is the differance between a SQL expression field and a formula field

Posted on 2011-02-21
3
Medium Priority
?
578 Views
Last Modified: 2012-06-21
What is the difference between a sql expression and a formula field you can use a sql expression to hold a formula but is that the best way to do something, I think I am missing the big picture
George
0
Comment
Question by:GeorgeSalet
[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
3 Comments
 
LVL 26

Accepted Solution

by:
Kurt Reinhardt earned 252 total points
ID: 34947657
At a high level, they're conceptually the same.  Basically, each can create a derived field.  You can concatenate objects together, perform calculations, etc..  One major difference, however, is that most formulas cannot be passed to the database for processing. If you include them in your record selection criteria then you run the risk of them not being passed, all possible records being brought down from the database, across the network, and then filtering out extraneous records on the client.  A SQL Expression field, however, is ALWAYS processed on the database.

As an example, I recently had a client who wrote record selection along the lines of {@value} = {?param} where the value was a huge string field with 6 numeric values in the middle of the field that needed to be stripped out and converted to a number (an account number).  The idea of the report is that the user will enter an account number and pull back only those records that match.  The problem is the formula can't be evaluated until all possible results are returned.  In other words, the query pulled back records for all accounts (100k plus records) first, then filtered them out in Crystal after they were returned.

I wrote a SQL Expression that was the equivalent of the formula and changed the criteria to {%value} = {?param}.  This resulted in the report returning data in seconds, not several minutes, and much smaller recordset (<100) being returned from the database.

SQL expressions can be full-fledged SELECT statements (with a result of a single, distinct value) or can be as simple as performing an UPPERCASE function against a string field.

Here are some presentations I've given that include information on SQL Expression:

The Power and Possibilities of SQL Expressions: https://www.box.net/shared/i2jk8yohku

Pro Tips for Common Reporting Scenarios: https://www.box.net/shared/ysqmn7eov5

Example of a complex SQL Expression for a client (DB2 SQL): https://www.box.net/shared/cn5lstmcjc

~Kurt
0
 
LVL 4

Assisted Solution

by:msd1305
msd1305 earned 248 total points
ID: 34949281
Summary of differences:
1)
- Formula field follows Crystal Syntax to write and evaluate the expressions
-SQL Expressions are written and evaluated in SQL syntaxes.

2)
- You can not call Database functions using formula field
- You can call database functions using SQL expressions.

3)
- You can not have running total on SQL expression fields.
- You can define running totals on Formula fields.

These are basic three differences.  The links rhinok provides are quite good and provide detailed information about the same.
0
 

Author Closing Comment

by:GeorgeSalet
ID: 34958055
Both explanations are Great
Thank You
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

777 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