Without fully understanding your query, I will say that TSQL allows for business logic, such as conditional statements, to be used within your SQL statements. I believe MS SQL Server and Sysbase support TSQL.

Hope it helps!