CREATE Procedure daycount
@Grad int,
@police Varchar(10),
@currenttime varchar(20)
as
if @Grad=0
begin
select (select hotelname from info_hotel where info_hotel.hotelcode=Info_Guest.hotelcode) as hotelname,Count(guestcode) as UpDataNum from info_Guest where substring(LoginTime,1,8)=@currenttime and hotelcode in (select PH.hotelcode from Info_hotel as PH where PH.ting=@police and hotelstatus = 1) group by HotelCode ORDER BY UpDataNum
end
GO