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

LIKE 1

Status
Not open for further replies.
Dec 16, 2008
83
GB
Crystal Server Management Studio 2005

Hi, i have a query with this line in it:

MAX(CASE tblTrans.PremiumID WHEN 'PI' THEN tblTrans.Premium ELSE 0 END) AS PINetPremium

i would like it now to say when it starts with PI, i know how to use the like and %, but am just not sure how to do it, any chance someone can give me some help?

Cheers
 
Code:
MAX(CASE WHEN tblTrans.PremiumID LIKE 'PI%'
              THEN tblTrans.Premium 
         ELSE 0 END) AS PINetPremium

--- or

MAX(CASE WHEN LEFT(tblTrans.PremiumID,2) = 'PI'
              THEN tblTrans.Premium 
         ELSE 0 END) AS PINetPremium


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top