We help IT Professionals succeed at work.

Using SELECT CASE with LIKE

almaler
almaler asked
on
959 Views
Last Modified: 2010-07-27
Here is my current query that works:
SELECT
CASE FileVersion
WHEN '9.0.2001.0219' THEN 'Microsoft Project 2000'
WHEN '9.0.2000.0224' THEN 'Microsoft Project 2000'
WHEN '11.2.2005.1801.15' THEN 'Microsoft Project 2003'
WHEN '11.1.2004.1707.15' THEN 'Microsoft Project 2003'
WHEN '11.0.2003.0816.15' THEN 'Microsoft Project 2003'
WHEN '10.0.2104.1305' THEN 'Microsoft Project 2002'
WHEN '10.0.2002.0502' THEN 'Microsoft Project 2002'
ELSE 'UNKNOWN'
END AS Version,

a.Name0 FROM v_R_System a INNER JOIN v_GS_SoftwareFile b on a.ResourceID = b.ResourceID WHERE  FileName LIKE 'winproj.exe' AND a.Name0 NOT LIKE  'aacobo%'
AND a.Name0 NOT LIKE 'aac-oig%'
AND a.Name0 NOT LIKE 'oig%'
AND a.Name0 NOT LIKE 'vaaac%'  ORDER BY Version ASC

What I want to do is change the CASE statement so that I can say
SELECT
CASE FileVersion
WHEN FileVersion LIKE '9.0.%' THEN 'Microsoft Project 2000'

OR something like

SELECT
CASE FileVersion
WHEN FileVersion STARTS WITH '9' THEN 'Microsoft Project 2000'

Is this possible?

Comment
Watch Question

Database Engineer
CERTIFIED EXPERT
Top Expert 2005
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Awesome!  How do I make a.Name0 come before b.Fileversion in the results set?
Brian CroweDatabase Engineer
CERTIFIED EXPERT
Top Expert 2005

Commented:
SELECT
   a.Name0,
   CASE FileVersion
      WHEN FileVersion LIKE '10.0.% THEN 'Something Else'
      ...
      ELSE 'UNKNOWN'
   END AS Version,
FROM v_R_System
...

Author

Commented:
Thank you!!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.