Solved

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

Posted on 2000-05-03
3
381 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Agreggate sums in sql 1 517
HOW to reterive specific datetime values from sybase iq 4 1,789
dbisql 5 548
sql anywhere query 5 134
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now