











CompTIA
Exam Vouchers
Save money on CompTIA exams
| Question of the day
Sign up to receive
interactive practice questions
for MCSE, CompTIA
Cisco and other exams
| TestKing
Get MCSE, MCSD, CCNA, CCNP,A+, N+ and many more | * ExamSheets *
Guide for Success!
Actual Questions & Answers
MCSE, MCSD, A+ ,CCNA, CCNP
Oracle 8i, Oracle 9i Online practice tests
Certification sites Online university Online college Online education Distance learning Software forum Server administration forum Programming resources
|
|  |
| Author |
Question about aliases
|
sjgross
Junior Member F
Registered: Nov 2002 Location: Country: United States State: Certifications: Working on: MCP, MCDBA
Total Posts: 29
|
|
Question about aliases
Hi folks,
In studying aliases I have the following query from the MS training guide
use northwind
select top 2 * from [Order Details]
select OrdD1.OrderID AS OrderID,
SUM(OrdD1.Quantity) AS "Units Sold",
SUM(OrdD1.UnitPrice * OrdD1.Quantity) AS Revenue
My question is in the second SUM statement where it says OrdD1.Quantity should it not be referred to as Units Sold?
Or is it different because the whole statement in the parentheses (OrdD1.UnitPrice * OrdD1.Quantity) is being assigned as the alias?
__________________
Best,
Susan
My Weblog about studying for MS 70-229 (Notes and Links)
http://ix.1sound.com/dbagirl
Report this post to a moderator
|
|
02-06-03 05:01 PM
|
|
MKSD
Junior Member M
Registered: Jan 2003 Location: London Country: United Kingdom State: Certifications: MCPx12, MCAD, MCSD/MCSD.Net Working on: MCDBA
Total Posts: 3
|
|
Hi,
You're mostly correct, i.e. the sum of (price times quantity) - not just the parenthesis but the whole summing operation on the multiplied result of (P*Q).
The "quotes" are used because there is a space in the column alias, the Revenue Alias is really required because without it you would have no column name in the resultset.
Aliasing is particularly useful to rename a column, provide a name where there isn't one, and also in cases where results are joined from multiple tables with the same column name, for example you may have two tables with an identically-named column (e.g. 'Sales'), you may alias the Sales columns as Domestic, and Export respectively, or whatever is appropriate to distinguish them.
The sample you're referring to demonstrates that you can alias an existing name, or provide one where there is none. I'm overstating the case here, sorry its an occupational hazard ;-)
HTH,
Martin
Report this post to a moderator
|
|
02-06-03 08:54 PM
|
|
naresh_sky
Member M
Registered: Sep 2002 Location: Country: India State: Certifications: 70-228(MCP) Working on: MCDBA,MCAD,MCSD.NET
Total Posts: 84
|
|
Hi susan,MKSD.
I agree with MKSD.
aliasing is also used when ur using the
self join based on a column where in u
give alias to join .
Cheer's
Naresh
Report this post to a moderator
|
|
02-10-03 01:16 PM
|
|
|
MCSE exam notes
Forum Rules: Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author.
Posts: HTML code is OFF. Smilies are ON. vB code is ON. [IMG] code is ON. |
|
ExamNotes forum archive
|