Solved

Derived Table Problem

Posted on 2008-10-10
4
451 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
  • 2
4 Comments
 
LVL 59

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 59

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

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

This article describes some very basic things about SQL Server filegroups.
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now