Select
  Rule.Priority,
  Rule.Name,
  Category1.Name As Name2,
  Category.Name As Name1,
  Case Rule.ApplyTo When 1 Then 'Bedrag bij' When 2 Then 'Bedrag af' When 3 Then 'Beide' End As BijAf,
  Case Rule.Operator When 0 Then 'Of' When 1 Then 'En' End As OfEn,
  Condition.AttributeName,
  Case Condition.Operator When 0 Then 'Gelijk aan' When 1 Then 'Ongelijk aan' When 2 Then 'Groter dan' When 3 Then 'Kleiner dan'
    When 4 Then 'Groter of gelijk aan' When 5 Then 'Kleiner of gelijk aan' When 6 Then 'Begint met' When 7 Then 'Eindigt met'
    When 8 Then 'Bevat' When 9 Then 'Bevat niet' When 10 Then 'Een van' When 11 Then 'Is Leeg' When 12 Then 'Is niet leeg'
  End As Operator,
  Condition.MatchingValue
From
  Rule Inner Join
  Category On Rule.CategoryId = Category.Id Left Join
  Category Category1 On Rule.MainCategoryId = Category1.Id Inner Join
  Condition On Rule.Id = Condition.RuleId
Order By
  Rule.Priority
