Solved

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

Posted on 2000-05-03
3
428 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 50 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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