T-sql codes for GLF