Subject Re: [firebird-support] Problem with Views since switching from IB
Author Helen Borrie
At 08:52 PM 7/10/2003 -0400, you wrote:

>I now get an invalid column reference with the following:
>
>(I am using FreeUDFLib)
>
>Any help would be appreciated.
>
>
>CREATE VIEW SUM_SALESBYDAYOFWEEK(
> ORDERTYPE,
> DAYOFWEEK,
> DAYOFWEEKNAME,
> TOTALSALES,
> ORDERDATE)
>AS
>SELECT OrdersPermanent.OrderType, F_DayOfWeek(OrderDate) As DayOfWeek,
>F_CDOWShort(OrderDate) As DayOfWeekName,
> Sum(OrdersPermanent.OrderSub) AS TotalSales,
>OrdersPermanent.OrderDate
>FROM
> OrdersPermanent GROUP BY OrderType, OrderDate;

This should work out OK if you remove the inconsistent table
identifiers. Either use all identifiers (OK but unnecessary for a
single-table spec) or none.

SELECT OrderType, F_DayOfWeek(OrderDate) As DayOfWeek,
F_CDOWShort(OrderDate) As DayOfWeekName,
Sum(OrderSub) AS TotalSales,
OrderDate
FROM OrdersPermanent
GROUP BY OrderType, OrderDate;

or (unnecessary)

SELECT OrdersPermanent.OrderType, F_DayOfWeek(OrdersPermanent.OrderDate) As
DayOfWeek,
F_CDOWShort(OrdersPermanent.OrderDate) As DayOfWeekName,
Sum(OrdersPermanent.OrderSub) AS TotalSales,
OrdersPermanent.OrderDate
FROM
OrdersPermanent GROUP BY OrdersPermanent.OrderType,
OrdersPermanent.OrderDate;

Fb 1.5 is a lot more fussy about grouping. If OrderDate is a Timestamp,
this might not work. In that case, try this instead:

GROUP BY OrderType, F_DayOfWeek(OrderDate)

h.