费用分摊问题的SQL语句
有宿舍表:
RS_Room : 字段为 RoomCode , EMoney
001 600
002 500
有床位表:
RS_Bed : 字段为 BedCode RoomCode EmpCode Flag(1:表示入住 0:表示空缺)
001-01 001 Em001 1
001-02 001 Em002 1
001-03 001 Em003 1
001-04 001 0
002-01 002 0
002-02 002 Em004 1
002-03 002 0
002-04 002 0
现在如何算出Em001这位员工的住宿分摊的住宿费用为:200元 ?