Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: SQL
sqlreadabilityquery-building
Alias aggregate/computed columns in SQL results
Give aggregate expressions a clear alias (COUNT(...) AS total) so the result property name is meaningful instead of the raw expression text.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codesql
| 1 | SELECT COUNT(DISTINCT(main_profiles.id)) FROM main_profiles |
Explanation (EN)
Objašnjenje (HR)
Good example
New codesql
| 1 | SELECT COUNT(DISTINCT(main_profiles.id)) AS mainProfilesIdCount FROM main_profiles |
Explanation (EN)
Objašnjenje (HR)