Need advise implementing Sql Query

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
vinod111
Participant
Posts: 5
Joined: Wed Oct 05, 2005 8:52 pm

Need advise implementing Sql Query

Post by vinod111 »

I am to create server job for the query: Select empno from emp where salary >avg(salary).. Please let me know
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

And do what with the result? Write it to another table, a text file, ftp to a mainframe, what? From what database, Oracle, UDB, SQL-Server, using what stage, OCI, ODBC, etc? Do you want user-defined or generated queries?

Your request is one of the first things you do in training. If you haven't had training, might I suggest using the tutorial?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DeepakCorning
Premium Member
Premium Member
Posts: 503
Joined: Wed Jun 29, 2005 8:14 am

Re: Sql Query

Post by DeepakCorning »

:lol:

Add a drs stage and add the column, table and where condition.
vinod111 wrote:I am to create server job for the query: Select empno from emp where salary >avg(salary).. Please let me know
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

don't specify the condition in the where clause, specify it in the other clauses since you are using avg(salary), use having option.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This is actually not possible in a single query. You need two passes through the data. You can do this with a nested query in the WHERE clause.

Code: Select all

column > (select avg(column) from table)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply