467,198 Members | 1,207 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,198 developers. It's quick & easy.

Syntax question DB2 UDB v8.1.9 Linux

The following query gives a syntax error if the 't1' is omitted, even
though it is never referenced. Could someone explain wy to me?

select count(*)
from ( select distinct birth_date
from is3.animals) t1

Apr 12 '06 #1
  • viewed: 1672
Share:
6 Replies
Bob Stearns wrote:
The following query gives a syntax error if the 't1' is omitted, even
though it is never referenced. Could someone explain wy to me?

select count(*)
from ( select distinct birth_date
from is3.animals) t1

Seems to work fine for me on one of my tables ... which version of DB2
are you using?
You may want to try ") AS T1"?
Apr 12 '06 #2
In article <K2***********@fe05.lga>, rs**********@charter.net says...
The following query gives a syntax error if the 't1' is omitted, even
though it is never referenced. Could someone explain wy to me?

select count(*)
from ( select distinct birth_date
from is3.animals) t1


"select count(distinct birth_date) from is3.animals" should work also.
Apr 12 '06 #3
Gert van der Kooij wrote:
In article <K2***********@fe05.lga>, rs**********@charter.net says...
The following query gives a syntax error if the 't1' is omitted, even
though it is never referenced. Could someone explain wy to me?

select count(*)
from ( select distinct birth_date
from is3.animals) t1

"select count(distinct birth_date) from is3.animals" should work also.

Thanks, I'd overlooked that. An unavoidable result of the manual's being
about features and not combinations thereof.
Apr 12 '06 #4
Bob [IBM] wrote:
Bob Stearns wrote:
The following query gives a syntax error if the 't1' is omitted, even
though it is never referenced. Could someone explain wy to me?

select count(*)
from ( select distinct birth_date
from is3.animals) t1

Seems to work fine for me on one of my tables ... which version of DB2
are you using?
You may want to try ") AS T1"?

Bob, which platform supports omission of the table alias?
I take any excuse to remove it (It can be annoying)

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Apr 12 '06 #5
Bob Stearns wrote:
The following query gives a syntax error if the 't1' is omitted, even
though it is never referenced. Could someone explain wy to me?

select count(*)
from ( select distinct birth_date
from is3.animals) t1


DB2 requires that you give such derived tables a name. That's just the way
it is, and there isn't really a problem with that, is there?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 12 '06 #6
Serge Rielau wrote:
Bob [IBM] wrote:
Bob Stearns wrote:
The following query gives a syntax error if the 't1' is omitted,
even though it is never referenced. Could someone explain wy to me?

select count(*)
from ( select distinct birth_date
from is3.animals) t1

Seems to work fine for me on one of my tables ... which version of
DB2 are you using?
You may want to try ") AS T1"?

Bob, which platform supports omission of the table alias?
I take any excuse to remove it (It can be annoying)

Cheers
Serge

Well duh on me -- I reversed the reading of the post! Never mind my
reply -- it is off kilter and today so am I.
Thanks for catching that Serge.
Apr 12 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Crew Reynolds | last post: by
11 posts views Thread by Andreas Neudecker | last post: by
699 posts views Thread by mike420@ziplip.com | last post: by
16 posts views Thread by George Sakkis | last post: by
2 posts views Thread by George Sakkis | last post: by
reply views Thread by Thiko | last post: by
reply views Thread by Berthold Höllmann | last post: by
177 posts views Thread by C# Learner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.