View Single Post

   
  #3 (permalink)  
Old 04-08-2008, 06:15 PM
alex
 
Posts: n/a
Default Re: Grouping by datepart() affected fields

En/na DA Morgan ha escrit:
> GROUP BY is used to group the results of an aggregating function
> such as summing or averaging values for a group. You are not
> doing that in your query.


sorry, i doubleposted. after finding this group i found
sybase.public.ase.general which had more recent messages...

the issue in this view was grouping by the alias name of the column
which seems not to be implemented in sybase.

i solved it by applying the same datepart conversions in the group by
clause:

create view
sybtestview
as
select
(
convert(varchar(4),datepart(yy,mydate))
|| '-'
|| convert(varchar(2),datepart(mm,mydate))
) sybdate

from sybtest
group by
(
convert(varchar(4),datepart(yy,mydate))
|| '-'
|| convert(varchar(2),datepart(mm,mydate))
)


this shows me the different months present in the sybtest table to which
i can apply other aggregate functions (for example count to get the
number of records for each month).
Reply With Quote