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 > Other > Group by calculated date not working

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Feb 2010
Posts: 38
Group by calculated date not working

Hi,

I'm having trouble getting a group-by query working. First I had this working bit of SQL:

Code:
select year(date1+numberofdays), week(date1+numberofdays), sum(qty) 
from pub.table 
group by year(date1+numberofdays), week(date1+numberofdays)
(date1 is a date and numberofdays an integer.)

The problem is that where I'm from, the week starts on Monday, but this database is using the North American standard where it starts with Sunday. So I thought I could just subtract the date with 1 day, but then I get a "non-group-by expression in select clause" error, with the SQL looking like this:

Code:
select year(date1+numberofdays), week(date1+numberofdays-1), sum(qty) 
from pub.table 
group by year(date1+numberofdays), week(date1+numberofdays-1)
But it works if I select the subtracted date without the aggregate function, like this:

Code:
select year(date1+numberofdays), week(date1+numberofdays-1), qty from pub.table
What's the problem? It's a Progress 10.1A database.

Thank you!
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