none
SQL to fetch xml RRS feed

  • 问题

  • //1
    select
    base.new_auditperson,count(base.new_auditperson) as cnt
    from 
    (
    select na.new_auditperson, format(na.createdon, 'yyyy-MM' ) as ry 
    from new_audittest as na
    inner join contact on na.contactid = contact.new_auditperson
    ) as base
    where base.ry=@ReportParameterMonth
    group by base.new_auditperson

    //2

    select mbase.mYear as lable, mbase.mYear as value from
    (select distinct YEAR(createdon) as mYear from new_audittest) mbase

    //3

    select
     res.m as vmonth
    , res.ry as value
     from (
    select distinct
    case when month(na.createon) < 4 then Year(na.createon) - 1 else year(na.createon) end as y
    ,month(na.createon) as m
    ,format(na.createdon, 'yyyy-MM' ) as ry
    from new_audittest as na
    ) as res
    where
     res.y = @ReportParameterYear
    order by res.ry

    以上3个SQL文怎么转换成Fetch Xml 的写法?

    2015年5月19日 9:43

全部回复

  • 自己给自己回复吧,MSDN也就这样,没几个愿意回答问题的。

    Fetch Xml 不支持子查询,如果硬是要用,那只能建一个view

    不能直接调用SQL里面的函数,比如year();


    2015年5月22日 5:12