Results 1 to 3 of 3

Thread: LEFT String Query in Crystal

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    4

    LEFT String Query in Crystal

    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 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 seem to get a formula to work in Crystal in record selection.

    Can somebody please help me with the correct syntax for both of those?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: LEFT String Query in Crystal

    Assuming SQL Server

    You can't use Left unless you are searching from the beginning of the string.
    ie Select * From table Where Left(Account_Code, 6) = 'PRCP35'

    Use SubString instead
    Select * From table Where Substring(Account_Code, 5, 2) = '35'

    In Crystal and Access use Mid
    Mid ({Table.Account_Code}, 5 , 2 ) = "35"
    Last edited by brucevde; Mar 15th, 2007 at 05:22 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    4

    Resolved Re: LEFT String Query in Crystal

    This worked great! Thank you!!!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width