Home / MySQL / SQL lessons – Naming Columns
MySQL allows you to name the displayed columns. So instead of f_name or l_name etc. you can use more descriptive terms. This is achieved with AS.
select avg(salary) AS 'Average Salary' from employee_data; +----------------+ | Average Salary | +----------------+ | 95095.2381 | +----------------+ 1 row in set (0.00 sec)
Such pseudo names make will the display more clear to users. The important thing to remember here is that if you assign pseudo names that contain spaces, enclose the names in quotes. Here is another example:
select (SUM(perks)/SUM(salary) * 100) AS 'Perk Percentage' from employee_data; +-----------------+ | Perk Percentage | +-----------------+ | 19.53 | +-----------------+ 1 row in set (0.00 sec)
How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]
About 8 billion electrons are used for an average email of 50KB. If one were to weight all these, it turns out that the message weighs about "two ten thousandths of a quadrillionth of an ounce". [more...]
We use cookies to give you the best possible website experience. By using WebDevelopersNotes.com, you agree to our Privacy Policy