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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LEFT string query

Status
Not open for further replies.

rose4567

Programmer
Mar 12, 2007
70
US
Hello friends,

I'm sure this has been asked before, but I can't make this query work for me as I am new to crystal.

I'm using Crystal Reports 10.

I need to search an Account Code string and find "35" at the 5th and 6th positions in the string.

The account code looks like this: PRCP353F5720-06101

The number "35" will ALWAYS be at the 5th and 6th position from the left in this field.

I know the below is not correct, but I need to query something like:

Select *
From table
Where Account_Code Left("35",5)

I also need to run the above in SQL to test my results. I can't make this work in SQL and can't get the syntax right in Crystal record selection either.

Does anyone know the correct syntax I should be using? Thank you in advance for your thoughts!!
 
In Crystal you would use a record selection formula like:

mid({table.Account_Code},5,2) = "35"

Or you could create a SQL expression like the following {%35}:

substr(table.`Account_Code`,5,2)

Or you might need to use:

{fn substring(table.`Account_Code`,5,2)}

Then you could change the record selection to:

{%35} = "35"

-LB
 
This works great! Thanks so much for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top