sql server - Order SQL query by the sum of specefic columns -
sql server - Order SQL query by the sum of specefic columns -      here extract  big table (sql server 2005) i'm querying against:    id (primary key) |   business relationship  |  phone  |  employee  | address ------------------------------------------------------------------ 1                |   123     |    y    |    y       |   n 2                |   456     |    n    |    n       |   n 3                |   789     |    y    |    y       |   y    i need  homecoming rows have @  to the lowest degree 1 y in phone, employee, or address (there 10 others not shown here). need order results number of y's have in of three.   i've tried getting "tagtotal" this:    select sum(   case when [phone] = 'y' 1 else 0 end   + case when [employee] = 'y' 1 else 0 end   + case when [address] = 'y' 1 else 0 end   )   table    grouping id    this returns:    tagtotal --------------- 2 0 3    i'm @ loss on how combine existing giant query , order without...