create table score( name ), math int, english int ); ,); ,); ,); ,); SHOW tables; SELECT * from score; --行列转换: select c2 as '课程', )) '甲', )) '乙', )) '丙', )) '丁' from( select name c1,'math' c2,math c3 from score GROUP BY name union select name,'englis
一.第一种 原数据表 转换后 DROP TABLE IF EXISTS tempdynamic; CREATE TEMPORARY TABLE tempdynamic ( SELECT p.fsPaymentName,sr.fsPaymentId,sh.fsShiftName,SUM(sr.fdReceMoney) as AmtTotal FROM tbsell as s INNER JOIN tbSellReceive as sr ON s.fsSellNo=sr.fsSellNo AND s
分类: Mysql/postgreSQL 在某些数据库中有交叉表,但在MySQL中却没有这个功能,但网上看到有不少朋友想找出一个解决方法,特发贴集思广义.http://topic.csdn.net/u/20090530/23/0b782674-4b0b-4cf5-bc1a-e8914aaee5ab.html?96198现整理解法如下: 数据样本: create table tx( id int primary key, c1 ), c2 ), c3 int ); insert into tx v
作为Oracle开发工程师,推荐大伙看看 PIVOT and UNPIVOT Operators in Oracle Database 11g Release 1 This article shows how to use the new PIVOT and UNPIVOT operators in 11g, as well as giving a pre-11g solution to the same problems. PIVOT UNPIVOT Related articles. PIV