Having a semantic layer to define structured query language (SQL) based metrics, allows end-users of business intelligence (BI) products to compose SQL queries on the fly, using a graphical user interface (GUI). This disclosure describes the use of a semantic layer to define SQL-based metrics which allows end-users of business intelligence (BI) products to compose SQL queries on the fly, using a graphical user interface (UI), with support for utilizing the results of an initial query to automatically compose a new query. The use of a modeling layer to enable query composition on the fly makes such operation simple, performant, and easy to execute, without requiring building an entire new application