title: T-SQL partition by for string columns
body: <p>I try to generate a new column by grouping other columns and the code below works.</p>
  
  <pre><code> CASE 
       WHEN familyGroupPOSRef = 955 
         THEN MAX(RVCPOSId) OVER (PARTITION BY organizationID, Location_Code, transactionID) 
         ELSE -1 
   END AS toEntity
  </code></pre>
  
  <p>Is there a way to run this code by using a string column? Using <code>LocationName</code> instead of <code>RVCPOSId</code> before <code>OVER</code> statement.</p>
  
  <pre><code>CASE 
      WHEN familyGroupPOSRef = 955 
        THEN LocationName OVER (PARTITION BY organizationID, Location_Code, transactionID) 
        ELSE 'nothing' 
  END AS toEntity
  </code></pre>
  
  <p>I could not find anything on the net so far. It does not have to be this method. I need to group <code>organizationID, Location_Code, transactionID</code> and display <code>locationName</code> for 955 in a separate column.</p>
  
  <p><strong>How it is now:</strong></p>
  
  <pre><code> organizationID   Code   transactionID   FGName         itemName
      10000         955    123456          Location       Liv Retail
      10000         103    123456          Internal Item  Chocolate Milkshake
      10000         103    123456          Internal Item  Strawberry Milk
      10000         103    123456          Internal Item  Milk
  </code></pre>
  
  <p><strong>How I want it to be</strong></p>
  
  <pre><code>organizationID   Code   transactionID   FGName         toEntity    itemName
  10000            955    123456          Location       Liv Retail  Liv Retail
  10000            103    123456          Internal Item  Liv Retail  Chocolate Milkshake
  10000            103    123456          Internal Item  Liv Retail  Strawberry Milk
  10000            103    123456          Internal Item  Liv Retail  Milk
  </code></pre>
  
  <p>A transaction can have multiple menuItems and also it has always 1 record for location which is kept like a menuItem. This is a trick. I like to create a new column to apply location name which is Liv Retail under toEntity in the sample data provided. </p>
  
  <p>Please let me know if I am after something impossible. Then I will break down the stmt and connect tables with join.</p>
  
  <p>Thanks in advance.</p>