if exists(Select Name From SySObjects Where Name = 'V_TEST' And Xtype ='V')
Drop View V_TESTdeclare @sql varchar(4000)
set @sql = ' create view V_TEST as select ProjectID'
select @sql = @sql + ',max(case PropertyID when '''+PropertyID+''' then Value end) ['+PropertyID+']'
from (select distinct PropertyID from ProjectProperty) as a
select @sql = @sql+' from ProjectProperty group by ProjectID'
exec(@sql)select * From V_TEST
Drop View V_TESTdeclare @sql varchar(4000)
set @sql = ' create view V_TEST as select ProjectID'
select @sql = @sql + ',max(case PropertyID when '''+PropertyID+''' then Value end) ['+PropertyID+']'
from (select distinct PropertyID from ProjectProperty) as a
select @sql = @sql+' from ProjectProperty group by ProjectID'
exec(@sql)select * From V_TEST
解决方案 »
- 令人疑惑的MySql版本号,官网最新版不是5.5么?怎么有09年的7.0版
- mysql行转化列 ?????
- mysql的问题 求一方法,在线等待
- 关于在脚本中判断select是否有返回值的问题
- a b的数据的汇总分析 (分布式事务)
- 关于mysql数据库和information_schema数据库可以删除吗?
- 莫名奇妙的问题,各位帮帮我吧!
- mysql数据文件的存储位置
- update 可以用事务处理吗?
- 求教大佬,想查询不以某串数字加一段字符串结尾的记录,sql怎么写?
- (求助)关于如何向有外键的表插入数据(只知道外键表其他属性 不知道id)
- MySQL/PostgreSQL文化衫(顶者有分)!!!
drop view if exists V_TEST;
set @sql = 'create view V_TEST as select ProjectID';
set @sql = concat(@sql,',max(case PropertyID when PropertyID then Value end) [PropertyID]','from
(select distinct PropertyID from ProjectProperty) as a');
set @sql =concat( @sql,' from ProjectProperty group by ProjectID');prepare s1 from @sql;
execute s1;
deallocate prepare s1;select * From V_TEST;
Unknown prepared statement handler (s1) given to DEALLOCATE PREPARE