有如下一个表:
   name 
-----------
 a20080321
 a20080320
    ...
    ...如何通过上表动态生成下面这段语句:select * from 

  select 代码 as stockCodeName , 日期 as date, Subject = '散户' , Result = 散户 from a20080321
  union all 
  select 代码 as stockCodeName , 日期 as date, Subject = '中户' , Result = 中户 from a20080321
  union all 
  select 代码 as stockCodeName , 日期 as date, Subject = '大户' , Result = 大户 from a20080321
  union all 
  select 代码 as stockCodeName , 日期 as date, Subject = '法人' , Result = 法人 from a20080321
  union all
  select 代码 as stockCodeName , 日期 as date, Subject = '机构' , Result = 机构 from a20080321
  union all
  select 代码 as stockCodeName , 日期 as date, Subject = '散户' , Result = 散户 from a20080320
  union all 
  select 代码 as stockCodeName , 日期 as date, Subject = '中户' , Result = 中户 from a20080320
  union all 
  select 代码 as stockCodeName , 日期 as date, Subject = '大户' , Result = 大户 from a20080320
  union all 
  select 代码 as stockCodeName , 日期 as date, Subject = '法人' , Result = 法人 from a20080320
  union all
  select 代码 as stockCodeName , 日期 as date, Subject = '机构' , Result = 机构 from a20080320
  ...
  ...
) t 
where stockcodename = '600000'
order by stockCodeName, date, 
 case Subject 
  when '散户' then 1 
  when '中户' then 2 
  when '大户' then 3 
  when '法人' then 4 
  when '机构' then 5 
 end