and serverid = (select serverid from serverlist where servername=@servername) go exec deleserveruse '张生','洗车-小车' select * from serveruse go
--15,随时查询顾客的应付金额 create proc guestcost @guestid int ,@total money output as declare @servercost money,@roomcost money select @servercost=sum(servercost) from serverlist where serverid in (select serverid from serveruse where guestid=@guestid) select @roomcost=roomtypelist.roomcost from roomtypelist where roomtypeid in (select roomtypeid from roomlist where roomlist.roomid in --用上面的结算 (select roomid from guestroom where guestid=@guestid)) select @roomcost=@roomcost* (select datediff(day,(select indate from guestroom where guestid=@guestid),getdate()) from guestroom where guestid=@guestid) select @total=@servercost+@roomcost