?
Solved

group by a computed column didn't work in sybase. why?

Posted on 2000-05-03
3
Medium Priority
?
431 Views
Last Modified: 2008-03-06
In Sybase adaptive server 11, the following gave me 'invalid column name mnth'. How can I summarize sales by month?

select sum( subtotal ) as sales_summary,
  datediff ( mm,  'Jan 1 2000', order_date ) as mnth
from sales_order
where mnth > 0
group by mnth
0
Comment
Question by:xander031
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
AlexJ030200 earned 150 total points
ID: 2774589
Hi xander031,

Try replacing mnth by its definition in the conditions of the query:

select sum( subtotal ) as sales_summary,
datediff ( mm,  'Jan 1 2000', order_date ) as mnth
from sales_order
where datediff ( mm,  'Jan 1 2000', order_date ) > 0
group by datediff ( mm,  'Jan 1 2000', order_date )
0
 

Author Comment

by:xander031
ID: 2774686
I wonder whether the query optimizer will eliminate redundant calls of the function?
0
 
LVL 2

Expert Comment

by:AlexJ030200
ID: 2774711
Sure it will, as long as they are written identically.
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question