Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

creating a view with min(datefield) ??

0 views
Skip to first unread message

Moshe Berlin

unread,
Nov 5, 2001, 5:11:55 PM11/5/01
to
how to create a view with a min(datefield) ?
The field names are all correct -
creation of the view without min() works fine,
but the creation of the view with min() gives the message "invalid
column".
select min(datefield) works, so the column is ok.

this is the view creation statement -
create view getfirstscores as
select
year,
category,
min(scoredate),
score
from scores

Thank you,
M. Berlin

Andrey Chernyakhovsky

unread,
Nov 5, 2001, 5:21:15 PM11/5/01
to
> create view getfirstscores as
> select
> year,
> category,
> min(scoredate),
> score
> from scores

You need to group by all columns that are not aggregated.


Moshe Berlin

unread,
Nov 6, 2001, 12:35:41 AM11/6/01
to
Hello Andrey, thanks-
OK, that is the normal way to select using aggregate functions, but I
got this error message - Is it asking for a name for a column to be
returned by the view? I haven't used views before, but now am starting.

>>Dynamic SQL Error
SQL error code = -607
Invalid command
must specify column name for view select expression
Statement: create view GetFirstScores as
select
yearcode,
divcode,
min(specdate) as first,
percent
from scores
group by
yearcode,
divcode,
percent

Moshe Berlin

unread,
Nov 6, 2001, 12:51:22 AM11/6/01
to
Hello Andrey,
Got it, this works now.
the 'view columns' make it return the values found.
Thanks for the help.

create view getfirstscores (yc,dc,pc) as
select
yearcode,
divcode,
min(specdate),


percent
from scores
group by yearcode, divcode, percent

0 new messages