If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Group by alias

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-30-09, 11:45
der_steph der_steph is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
Group by alias

Hey,

i want to form a selection where i can group by an alias:


Code:

select count(nr),to_char(dat, '%Y') as year
from table
where dat between "2005-01-01" and "2009-12-31" and nr=1
group by year

I´d like to build a group for each year to get an yearwise count

But informix doesn´t allow me to use such a group
Reply With Quote
  #2 (permalink)  
Old 11-30-09, 17:30
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Why not? If I make your query like:
Code:
SELECT to_char(dat, '%Y') year, count(*) number
FROM table                                     
WHERE dat BETWEEN '2005-01-01' AND '2009-12-31'
AND nr = 1                                     
GROUP BY 1
I get the result you described.

Regards,
Hans
Reply With Quote
  #3 (permalink)  
Old 12-01-09, 13:48
ceinma ceinma is offline
Registered User
 
Join Date: Apr 2007
Location: Jundiai / SP - Brasil
Posts: 311
Unfortunately this syntax isn't supported... must copy all column or use number like Tyvelen suggest
__________________
________________________________________
César Inacio Martins
Jundiai / SP - Brasil
http://www.imartins.com.br/informix - em Português
http://www.imartins.com.br/informix - English (translated by Google).
________________________________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On