Solved

Derived Table Problem

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql update 2 39
SQL syntax question 6 44
CentOS Backup Options 3 19
MS SQL Server Management Studio R2 4 32
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…

730 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