title: When Statments with LIKE and Substrings
body: <p>I am in school and trying to figure out this question asked by the instructor. I have not asked the instructor because he usually gets back to me 2 weeks down the road.</p>
  
  <p>Here is what the questions is asking:</p>
  
  <p>Using the weblog table in your database create a query that will use the WHEN statement to:</p>
  
  <p>categorize the records by the origcmd field meeting the following conditions
  Your categories should be as follows: </p>
  
  <p>•Category 1 = origcmd starts with GET</p>
  
  <p>•Category 2 = origcmd starts with POST</p>
  
  <p>•Category 3 = origcmd starts with HEAD</p>
  
  <p>•Category 4 = All of the left over records</p>
  
  <p>•Count the records in each group
  •Average the hours part of the origdate field without modifying the field.</p>
  
  <p>I have tried the following without the Average because I cannot get it to pull correctly with the following:</p>
  
  <pre><code>Select CASE 
  WHEN origcmd LIKE "GET%" THEN "Category 1"
  WHEN origcmd LIKE"POST%" THEN "Category 2"
  WHEN origcmd LIKE "HEAD%" THEN "Category 3"
  Else "Category 4 All of left over records" END as "Original CMD",
  Count(*) AS Total
  FROM WebLog 
  </code></pre>
  
  <p>When using this it only pulls the first WHEN line and ignores all the rest except the count. I am new at this and am having a difficult time trying to understand MySQL. I think I might need to use a SubString cmd but was hoping for a little direction here that might help.</p>
  
  <p>Regards,</p>