大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
SET @EE='';
创新互联为客户提供专业的网站设计、做网站、程序、域名、空间一条龙服务,提供基于WEB的系统开发. 服务项目涵盖了网页设计、网站程序开发、WEB系统开发、微信二次开发、成都手机网站制作等网站方面业务。
SELECT @EE:=CONCAT(@EE,'SUM(IF(C2=/'',C2,'/'',',C3,0)) AS ',C2,',') FROM (SELECT DISTINCT C2 FROM TX) A;
SET @QQ=CONCAT('SELECT ifnull(c1,\'total\'),',LEFT(@EE,LENGTH(@EE)-1),' ,SUM(C3) AS TOTAL FROM TX GROUP BY C1 WITH ROLLUP');
PREPARE stmt2 FROM @QQ;
EXECUTE stmt2;
这个好复杂,你学的是mysq吗?
/* 使用方法 直接执行 传入参数(series_guid 查询条件)返回一个数据集 如 查询该系列Cylindrical 下所有产品 dbo P_GetSeriesProductDetail Cylindrical 查询系列Cylindrical 下含有BK 的产品 dbo P_GetSeriesProductDetail Cylindrical product_name like %BK % */ CREATE PROCEDURE P_GetSeriesProductDetail(@series_guid varchar( ) @condition varchar( )) AS DECLARE @ParamNo nvarchar( ) DECLARE @SQL nvarchar( ) Set @SQL= DECLARE P_cursor CURSOR local fast_forward FOR SELECT param_no FROM V_product_params where series_guid=@series_guid OPEN P_cursor
FETCH next FROM P_cursor INTO @ParamNo WHILE (@@fetch_status = ) BEGIN Set @SQL = @SQL + MAX(CASE param_no WHEN + @ParamNo + THEN param_value ELSE END) AS F + @ParamNo + char( ) FETCH next FROM P_cursor INTO @ParamNo END
CLOSE P_cursor DEALLOCATE P_cursor Set @SQL= SELECT type_guid series_guid product_no product_name + @SQL + FROM V_product_params WHERE series_guid= + @series_guid + if (LTrim(@condition) ) Set @SQL= @SQL + and + @condition Set @SQL= @SQL + GROUP BY type_guid series_guid product_no product_name
lishixinzhi/Article/program/MySQL/201311/29566
\--我写下我的思路吧--\
--先取工号姓名,如果考勤表.EMPLOYEEID=员工表.employeeID,则--\
select b.employeeno 工号,b.name 姓名 from atten a,employee b
where a.employeeid=b.employeeID --假设考勤表是atten--
--------------------------------------
\--行转列,将1号到30号,从IN_TEIM、OUT_TIME中获取
select
if (IN_TIME like '01.11%',RIGHT(IN_TIME,5),null) as '1号上班'
if (OUT_TIME like '01.11%',RIGHT(OUT_TIME,5),null) as '1号下班'
from ATTEN group by IN_TIME,OUT_TIME
--如何实现将多个数值写到一个字段中,还需要再研究下。大体思路就这这样。--\