상세 컨텐츠

본문 제목

발자취

청강컴정/09DataBase중간고사

by luckey 2009. 4. 23. 22:10

본문

declare @mNum int
set @mNum = 2

select top(10) cNum, name, vDay from
(
 select fk_member as mNum, fk_cafe as cNum,
 row_number() over(partition by fk_cafe order by visit_date_day desc) as rank,
 visit_date_day as vDay
 from member_visit
 where fk_member =@mNum
) as mv
inner join cafe as cf
on mv.cNum = cf.sn
where rank = 1 and cast(vDay as datetime) > getdate()-7
order by vDay desc

관련글 더보기

댓글 영역