Solved

Derived Table Problem

Posted on 2008-10-10
4
459 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
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…

838 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