#1  
Old 30th June 2004, 11:54 PM
jay smurch
 
Posts: n/a
Default group by extract() error

I run this, to get a count of items by year, I get an error saying the
EXTRACT in line 3 is an invalid SQL name.

SELECT EXTRACT(YEAR FROM dt), count(*)
FROM "transactions"
GROUP BY EXTRACT(YEAR FROM dt)

"dt" is a Date column. Isn't this supposed to work?

Regards.


  #2  
Old 1st July 2004, 01:00 AM
Eivind Bakkestuen [NDD]
 
Posts: n/a
Default Re: group by extract() error

> SELECT EXTRACT(YEAR FROM dt), count(*)
> FROM "transactions"
> GROUP BY EXTRACT(YEAR FROM dt)


It will likely work if you add an alias to the select expression, and group
by the alias. Wether or not the above should work I leave to more SQL savvy
people.

--

Eivind Bakkestuen [NDD]
Please, no email unless requested.
Search Borland and third-party newsgroups here: www.tamaracka.com


  #3  
Old 1st July 2004, 01:43 AM
jay smurch
 
Posts: n/a
Default Re: group by extract() error

On Thu, 1 Jul 2004 00:00:07 +1000, "Eivind Bakkestuen [NDD]"
<Ieivind.bakkestuenHATE@nexusdb.comSPAM> wrote:

>> SELECT EXTRACT(YEAR FROM dt), count(*)
>> FROM "transactions"
>> GROUP BY EXTRACT(YEAR FROM dt)

>
>It will likely work if you add an alias to the select expression, and group
>by the alias. Wether or not the above should work I leave to more SQL savvy
>people.


It does, thanks:

SELECT EXTRACT(YEAR FROM "dt") "Date", count(*)
FROM "transactions"
GROUP BY "Date"

However, the <ahem> manual implies that an alias is not needed (see
G.6.4.13 EXTRACT example). Please to tell the documentation scrivner
that the number of errors and omissions in the manual is now > 0.

Regards.

  #4  
Old 1st July 2004, 02:22 AM
Ole Willy Tuv
 
Posts: n/a
Default Re: group by extract() error

<< Wether or not the above should work I leave to more SQL savvy people.
>>


Standard SQL requires that grouping columns reference a column by its name,
i.e. the column alias if specified or the real column name if an alias is
not specified. NexusDB allows grouping columns to be specified by the column
name or alias interchangeably.

Ole Willy Tuv




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Error: NexusDB: <unnamed TnxQuery instance>: Query execution failed Warren nexusdb.public.support.adoprovider 1 8th April 2010 02:55 PM
Error SQL for Insert with Group with Non-aggregate column (constant) hhlee nexusdb.public.support.sql 11 21st November 2003 10:53 PM
Question on Extract/subquery Don Miller nexusdb.public.support.sql 20 11th October 2003 08:26 PM
NX1.01: Cast with Group By Error Joao Borges nexusdb.public.support.sql 3 10th October 2003 05:19 AM
NX1 - 'Select' Extract incorrect record when it work with Chinese Forest Greenland nexusdb.public.support.sql 0 29th September 2003 10:33 PM


All times are GMT +11. The time now is 04:17 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.