I am interested in a piece of SQL that I have just seen, I don't understand
the need for the AS clause in the select statement.
IE
CREATE TABLE bill
(
VERS,
CAT_NAME,
ITEM_TYPE,
ITEM,
OLD_ITEM,
ACCNBR_ACC,
SECMASK1,
OLD_SECMASK1,
SECMASK2
)
AS <--- I understand this one ...
SELECT
VERS,
CAT_NAME,
ITEM_TYPE,
replace(ITEM,'98','99') as ITEM, <---- but not this
ITEM AS OLD_ITEM,
ACCNBR_ACC,
replace(SECMASK1, '98','99') as SECMASK1, <--- or this
SECMASK1 as OLD_SECMASK1,
SECMASK2
FROM
blah blah blah
);
surely the table bill would be created the positional order of the
colum names?? Even then the column could be aliased.
Thanks
See Ya
(when bandwidth gets better ;-)
Chris Eastwood
Photographer, Programmer email ua.ude.ug.cti@doowtsae.c
Motorcyclist and dingbat WWW http://chrise.itc.gu.edu.au
please remove undies for reply
************************************************************************
Ohhh ... you work all day, slave over a hot stove all night
yet you *still* have time for sadomasochism ... how do you do it?
A little man hurts me.
<ding>
Oh Mister Mean ... Oh Mister Mean
15 Minutes with him and you'll be blue and green
Studded belts and leather whips
Bondage trousers on his hips
Wack and punish as you dust with Mister Mean
Ohhhh he whips me around the house in minutes ... lets get cracking ...
eg select to_char(datefield,'dd-mon-yy hh24') as TIME
or
select to_char(datefield,'dd-mon-yy hh24')TIME
either way renames the column to TIME instead of to_char(datefield,'dd-mon-yy
hh24').
Hope it helps.
In article <75cafk$bql$1...@kraken.itc.gu.edu.au>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
[note: syntactically the two words belong together
"AS SELECT "]
> VERS,
> CAT_NAME,
> ITEM_TYPE,
> replace(ITEM,'98','99') as ITEM, <---- but not this
> ITEM AS OLD_ITEM,
> ACCNBR_ACC,
> replace(SECMASK1, '98','99') as SECMASK1, <--- or this
> SECMASK1 as OLD_SECMASK1,
> SECMASK2
> FROM
> blah blah blah
> );
>
> surely the table bill would be created the positional order of the
> colum names?? Even then the column could be aliased.
>
> Thanks
>
> See Ya
> (when bandwidth gets better ;-)
>
> Chris Eastwood
> Photographer, Programmer email ua.ude.ug.cti@doowtsae.c
> Motorcyclist and dingbat WWW http://chrise.itc.gu.edu.au
>
Think about how ORACLE names columns in a select statement and
you'll understand why the AS clause is required in the second and
third instance. In other words, without the AS clause, the column
would be named
REPLACE(ITEM,'98','99')
instead of ITEM. It could get tricky to work with that way. 8^)
I hope that helps.
ed
--
Ed Prochak
Magic Interface, Ltd.
440-498-3702
In article <75dmfh$rqq$1...@nnrp1.dejanews.com>, a...@interchange.co.uk wrote:
>The 'as' is used to stipulate what follows is a column alias (but the as is
>optional).
>
>eg select to_char(datefield,'dd-mon-yy hh24') as TIME
>or
>select to_char(datefield,'dd-mon-yy hh24')TIME
Ahhh ... thanks ... I have used the aliasing "optioning out" the as for so
long that I didn't know that the "option" existed.
I learn something new every day ... well most days, not like yesterday, which
brings the average down a little, but I should think that its a good 5 out of
7 days.......
;-)
See Ya
(when bandwidth gets better ;-)
Chris Eastwood
Photographer, Programmer email ua.ude.ug.cti@doowtsae.c
Motorcyclist and dingbat WWW http://chrise.itc.gu.edu.au
please remove undies for reply