使用SQL server中的row_number()生成的字段要怎么引用,是必须要外面再套一个select才能用吗?下面这种写法会报number不存在,但其实是能查出来的,只是不能在where后面用
select row_number()over(partition by p.typeid order by OutFactoryDate desc) as number,
pts.TaxPrice,sb.OutFactoryDate,sb.BillNumberID,p.* from ptype p
left join PriceTrack_Sale pts on p.typeid = pts.ptypeid
left JOIN SaleBill sb on pts.ptypeid = sb.ptypeid
where number=1