sql语句 :根据2个条件查询一个表,返回一个数组

图片说明
这个log表和student internship这来个类多对一,我通过log中的studentId

internshipId来查询对应的所有LOG对象,保存在一个数组中返回到对应的Acion

 public List<Log> findByStudentAndInternship(Long studentId, Long internshipId) {


        return (List<Log>) getSession().createQuery(//
                "FROM Log u FROM internship_log WHERE u.studentId=? AND u.internshipId=? ")//
                .setParameter(0, studentId)//
                .setParameter(1, internshipId)//
                .list();
    }

这么写不对

datediff(day,t1.FcheckDate, getdate())as 账龄 来进行日期相减Select top 1 u2.fnumber as 仓库代码,u2.FName as 仓库名称,ti.fnumber as 物料代码 ,ti.FName as 物料名称 ,ti.FModel as 型号,u1.FBatchNo as 批号,tm.FName as 基本单位,cast(u1.FQty as numeric(18,0)) as 基本单位数量,convert(nvarchar,t1.FDate,111) as 制单日期,convert(nvarchar,t1.FcheckDate,111) as 入库日期,datediff(day,t1.FcheckDate, getdate())as 账龄from icinventory u1,t_ICItem ti,t_MeasureUnit tm,t_Stock u2,ICStockBill t1,ICStockBillentry t2where tm.FItemID=ti.funitid and t1.FInterID=t2.FInterID and u1.FStockID=u2.FItemID and u1.FItemID=ti.FItemIDand u1.FQty>0and u1.FBatchNo is not nulland u1.FBatchNo<>''and u1.FBatchNo<> 'KB' and u1.FBatchNo<> '*'and t1.FTranType=2and t2.FBatchNo=u1.FBatchNoand getdate()-convert(nvarchar,t1.FcheckDate,111)>15