主表 food  
corpid,fdate,pid,type
明细表 datas
caseid,casename,nums,price要求按照类别进行转换为列
要求:
【corpid,fdate,pid,type,食品1,数量,价格,金额 ,食品2,数量2,价格,金额2...】
这样的效果
 
Dim strsql As String
strsql = "select f.corpid,f.fdate,120) as 日期"
strsql += ",f.pid as 编号 ,f.type as 类型"‘获取食品列表
Dim strtemp As String
For Each ob As FoodDll.Model.Suitcase In lst
    If ob.CaseName <> "" Then
          strtemp+ =iif(strtemp="","",",")+ " max(case d.caseid when " + ob.Case_id.ToString + " then d.nums else 0 end) as " + ob.CaseName
          strtemp += ",max(case d.caseid when " + ob.Case_id.ToString + " then d.price else 0 end) as 单价" + ob.Case_id.ToString
          strtemp += ",max(case d.caseid when " + ob.Case_id.ToString + " then d.price*d.nums else 0 end) as 合计" + ob.Case_id.ToString
    end if
next 
        strsql += IIf(strtemp = "", "", "," + strtemp)
        strsql += " from food f left join datas d on f.f_id=d.f_id "        strsql += " where  " 
        strsql += " year(f.fdate)=2013"  
        strsql += " and month(f.fdate)=3" 
        strsql += " group by f.corpid,Convert(varchar(10) ,f.fdate, 120)"
        strsql += ",f.pid,f.ptype "
        Return SqlHelper.ExecuteDataTable(strsql)
       
查询无错误,但为什么没有数据呢,都是零,问题在哪里?请教
行列