Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Command/Field Explorer

Status
Not open for further replies.

richiew13

Technical User
Mar 7, 2006
20
US
I have a crystaluser.com training guide. In the lesson about using the Add Command prompt, it tells me to access the sample database with a simple SQL statement in the Add Command function.

In my guide, after I add the Command, it shows 4 fields with their original names as the titles. ("Customer Name", "Region", etc.)

But when I run the exact same SQL command as in the book, my 4 fields are titled "Expr1000", "Expr1001" etc.

Why the difference?

I am using CR XI. The book is supposedly using CR v.9 if that makes a difference.
 
Rather than talk about it, post what you used as the add command, and the type of database.

An Add Command is the same as a SQL Query.

-k
 
I think you will get the "expr 1000" when you create a summary within the command without naming it, so you might try something like:

Select max(table.`date`) as maxdate, table.`customer` //etc.

-LB
 
I used this SQL query in the Add Command dialogue:

SELECT "Customer Name", "Region", "Country", "Last Year's Sales"
FROM Customer


I did this on the Xtreme Database example that came with Crystal XI.
 
Perhaps the "Last Year's Sales" is illegal.

As LB states, alias the field:

SELECT "Customer Name", "Region", "Country", "Last Year's Sales" Sales
FROM Customer

My Customer table doesn't have a last tears sales so I can't test.

-k
 
If you're using the Xtreme database, I think the syntax would be:

SELECT Customer.`Customer Name`, Customer.`Region`, Customer.`Country`, Customer.`Last Year's Sales`
FROM `Customer` Customer

-LB
 
You can use the "" in a Command object for Access as well, but LB is correct, that is how Crystal builds it out, try it.

-k
 
lbass, thanks. I copied your version and pasted it and it worked. I know very little about SQL queries.

It looks like your version has two changes from mine (which came straight from my book). You added: Customer. in front of each field, and you used " instead of '.

What does each of those things do?

Do you think my textbook just has the wrong code in there, or has something changed between CR-9 and CR-XI?
 
I'm not an expert in this area either, but the "Customer" in front of each field refers to the table name (actually the alias table name as indicated in the "From" line--the table name is in `` and the alias immediately follows). The marks aren't actually apostrophes--I don't know what they are called, but the mark is found on a key in the upper left of (mine, anyway) the numeric row.

The punctuation and syntax that is appropriate in the SQL query varies based on your datasource and your connectivity. If you are not sure, it might help to look at a report using the same datasource->database->show SQL query. Observe the punctuation and syntax there, and then use the same in the command object.

-LB
 
The character is a single open quote.

I'm surprised that the training guide had it wrong though, there may be something else amiss here.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top