Solved

Derived Table Problem

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…

863 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

19 Experts available now in Live!

Get 1:1 Help Now