Solved

Derived Table Problem

Posted on 2008-10-10
4
462 Views
Last Modified: 2013-12-24
I am trying to use a derived table as part of a query in informix. I am tring to show the maximum date from it.

I keep getting error messages, which are not helpful i.e. Unknown error message number '-201'

select a.activity_date
from
(select casact.caseid, max(casact.activity_date)
from arista01:student1.casact casact
group by casact.caseid) a

Does anybody know the correct syntax for the above query?

Thanks
0
Comment
Question by:halifaxman
[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
4 Comments
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 22695259
I am not Informix inclined; however, from a straight SQL Syntax point of view, the:
max(casact.activity_date)

Does NOT automatically retain column name of activity_date.  This is an expression, so you are going to get an untitled column or Expr1 or something to that effect.  Then in your outer query you are wanting to call by name activity_date, so you will need to do something like this:
max(casact.activity_date) AS activity_date

That will alias the expression back to a column name of activity_date.
0
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 22695269
Here is a nice blog post on the subject.  It shows amongst other things that you are define the columns in the alias for the derived table itself.

e.g.
a(caseid, max_activity_date)

Will make more sense, when you read this:
http://informix-technology.blogspot.com/2007/06/cheetah-spot-by-spot-derived-tables-in.html
0
 

Author Comment

by:halifaxman
ID: 22698525
Thanks for the answers, I will have a look at what you suggest
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
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…

688 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