with tt as (select A.GID, CASE WHEN A.IsApp='是' THEN 'APP' else '' end 'APP', CASE WHEN A.IsSmallApp='是' THEN '小程序' else '' end 'SmallApp' from Order A ) select A.SalePrice,A.SaleStatus, --销售参与渠道 --(A.IsApp+','+A.IsSmallApp), --CASE WHEN A.IsApp='是'
今天记录一下在oracle中多个字段如何和合并成一个字段,使用到符号“||” 1.组合查询的数据 1)组合前查询的语句 -- 组合前数据的字段 -- select A.MID CATE_ID,A.Code CATE_CODE,A.Name CATE_NAME,A.GoodsType GOODS_TYPE_ID,B.Text GOODS_TYPE_NAME from Dxc_Goods_Cate A left join SysState B on A.GoodsType = B.Value and
查询所有用户及角色,一个用户会有多个角色 select u.*,sr.* from users u left join sys_user_role sur on sur.userCode=u.id left join sys_role sr on sr.roleCode=sur.roleCode 结果 将用户的角色合并为一个字段 select u.*,GROUP_CONCAT(DISTINCT(sr.roleCode)) from users u left join sys_user_role
原SQL AND acc.id = accRole.acc_id) AND accRole.role_id = T_PM_ROLE.id ORDER BY acc.id 结果,有一个人有两个角色,如果想要将两个角色合并该如何呢? 答案:使用 group_concat函数 注:group_concat只有与group by语句同时使用才能产生效果 AND acc.id = accRole.acc_id) AND accRole.role_id = T_PM_ROLE.id GROUP BY acc
未合并情况 SELECT a.id, b.name AS "role" FROM sys_user a INNER JOIN sys_user_role c ON a.id=c.user_id INNER JOIN sys_role b ON b.id =c.role_idWHERE a.del_flag=0 AND b.del_flag=0 结果 id role 1 系统管理员1 测试角色2 系统管理员2 测试角色9 系统管理员9 测试角色d11828f3dbf148829287a
http://blog.csdn.net/cuixianlong/article/details/74024846 1 字段合并 原始数据如下:表名为Employee ID FirstName LastName Salary 1 Ming Zhang 8000 2 Lei Li 16000 查询SQL: SELECT ID, FirstName || ' ' || LastName AS Name, Salary FROM Employee 查询结果: ID Name Salary 1 Ming
sql server 字段合并(CAST) ---------------------- select (CAST(org_no AS VARCHAR(20))+CAST(page_no AS VARCHAR(20))+CAST(djlb_no AS VARCHAR(20))) from ERP_BASIC_BILLNO_PREFIX where org_num=#{orgNum} and page_name=#{pageName} and djlb_name=#{djlbName};") 字段
例如:有表MO_Cook,字段:FoodRoom,name 有如下数据: 要求:将FoodRoom中值相同的字段合并成一行,并将name的值用逗号隔开. 需要用到:STUFF函数. 查询语句如下: select FoodRoom, stuff((select ','+name from MO_Cook where c.FoodRoom=FoodRoom ,,'') as CookNames from MO_Cook c group by c.FoodRoom 查询结果如下: STUFF (
Expression构建DataTable to Entity 映射委托 1 namespace Echofool.Utility.Common { 2 using System; 3 using System.Collections.Generic; 4 using System.Data; 5 using System.Linq.Expressions; 6 using System.Reflection; 7 using System.Reflection.Emit; 8 9 publ
关于和并列的 要这种效果. create table tb(idint, value varchar(10)) insert into tbvalues(1,'aa') insert into tbvalues(1,'bb') insert into tbvalues(2,'aaa') insert into tbvalues(2,'bbb') insert into tbvalues(2,'ccc') go /* stuff(param1, startIndex, length