Sql case

 1 string strSql = "select samlid,";
 2                 strSql = strSql + "case bagclass ";
 3                 strSql = strSql + " when 1 then '小学' ";
 4                 strSql = strSql + " when 2 then '初中' ";
 5                 strSql = strSql + " when 3 then '高中' ";
 6                 strSql = strSql + " end,";
 7                 strSql = strSql + " Name fron QuestionsClass";
 8        if(strWhere.Trim()!="")
 9        {    
10                     strSql = "where" + strWhere;
11        }
12        return DbHelperSQL.Query(strSql.ToString());
原文地址:https://www.cnblogs.com/dqh123/p/9470018.html