I recently gone through something and found a unique way of aliasing. I thought it must be share so other techies also aware of it (or might be you already aware of it).
See below example
SELECT *
FROM (VALUES ('Rajat',30),
('Sandeep',40),
('Sunil',35),
('Shreya',50),
('Virendra',45)) AS T(Name,Runs)
Now when you it you will get following result
I hope you may like this tips.
Enjoy!!!
RJ!!!
Nice!
ReplyDeleteBeats having something like
SELECT 'Rajat' as Name, 30 as Runs
UNION ALL
SELECT 'Sandeep', 40
UNION ALL
SELECT 'Sunil', 35
UNION ALL
SELECT 'Shreya', 50
UNION ALL
SELECT 'Virendra', 45
Available since SQL Server 2008, documentation available here:
https://msdn.microsoft.com/en-us/library/dd776382.aspx
Well that's handy! Cheers mate.
ReplyDelete