dbTalk Databases Forums  

SQL Statement

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss SQL Statement in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mrdjmagnet@aol.com
 
Posts: n/a

Default SQL Statement - 02-24-2009 , 03:10 PM







Hello,

Can you have a select statement that returns a literal AND normal
query results without a UNION?

Say I have a parameter, like and employee ID, passed to a procedure.
I want to run a query which returns the top 4 records in the result
set PLUS the values from the employee ID passed in.......So, 5 records
total.

The query is long, so I'm hoping to do it without a UNION.......

Much Thanks

Reply With Quote
  #2  
Old   
ddf
 
Posts: n/a

Default Re: SQL Statement - 02-24-2009 , 03:20 PM






On Feb 24, 3:10*pm, mrdjmag... (AT) aol (DOT) com wrote:
Quote:
Hello,

Can you have a select statement that returns a literal AND normal
query results without a UNION?

Say I have a parameter, like and employee ID, passed to a procedure.
I want to run a query which returns the top 4 records in the result
set PLUS the values from the employee ID passed in.......So, 5 records
total.

The query is long, so I'm hoping to do it without a UNION.......

Much Thanks
Provide an example of the output you want to see, as well as the table
definition and some sample data.


David Fitzjarrell


Reply With Quote
  #3  
Old   
mrdjmagnet@aol.com
 
Posts: n/a

Default Re: SQL Statement - 02-24-2009 , 03:26 PM



On Feb 24, 3:20*pm, ddf <orat... (AT) msn (DOT) com> wrote:
Quote:
On Feb 24, 3:10*pm, mrdjmag... (AT) aol (DOT) com wrote:

Hello,

Can you have a select statement that returns a literal AND normal
query results without a UNION?

Say I have a parameter, like and employee ID, passed to a procedure.
I want to run a query which returns the top 4 records in the result
set PLUS the values from the employee ID passed in.......So, 5 records
total.

The query is long, so I'm hoping to do it without a UNION.......

Much Thanks

Provide an example of the output you want to see, as well as the table
definition and some sample data.

David Fitzjarrell
Well, say that an employee ID of 250 was passed in and a query was
run, I would like to see the following output with all the column data
of course:

250 <-- passed in
134
176
334
876

Of course column data is included. So it is the 4 records which match
the criteria, plus the values from the parameter passed in. This is a
dynamic query which will be read from another application.

As for the tables, there are 5 involved in this query. It is somewhat
a lot of information to post here. But, the employee ID is the tie
between all the tables....

Much Thanks




Reply With Quote
  #4  
Old   
mrdjmagnet@aol.com
 
Posts: n/a

Default Re: SQL Statement - 02-24-2009 , 03:28 PM



On Feb 24, 3:20*pm, ddf <orat... (AT) msn (DOT) com> wrote:
Quote:
On Feb 24, 3:10*pm, mrdjmag... (AT) aol (DOT) com wrote:

Hello,

Can you have a select statement that returns a literal AND normal
query results without a UNION?

Say I have a parameter, like and employee ID, passed to a procedure.
I want to run a query which returns the top 4 records in the result
set PLUS the values from the employee ID passed in.......So, 5 records
total.

The query is long, so I'm hoping to do it without a UNION.......

Much Thanks

Provide an example of the output you want to see, as well as the table
definition and some sample data.

David Fitzjarrell

The other way, is to possibly run a query that would return only the 4
employee ID's, excluding the one passed in, and then create the
dynamic query string using an IN clause, with the 4 from the previous
query plus the one passed in.....

That would work.



Reply With Quote
  #5  
Old   
ddf
 
Posts: n/a

Default Re: SQL Statement - 02-24-2009 , 03:42 PM



On Feb 24, 3:28*pm, mrdjmag... (AT) aol (DOT) com wrote:
Quote:
On Feb 24, 3:20*pm, ddf <orat... (AT) msn (DOT) com> wrote:





On Feb 24, 3:10*pm, mrdjmag... (AT) aol (DOT) com wrote:

Hello,

Can you have a select statement that returns a literal AND normal
query results without a UNION?

Say I have a parameter, like and employee ID, passed to a procedure.
I want to run a query which returns the top 4 records in the result
set PLUS the values from the employee ID passed in.......So, 5 records
total.

The query is long, so I'm hoping to do it without a UNION.......

Much Thanks

Provide an example of the output you want to see, as well as the table
definition and some sample data.

David Fitzjarrell

The other way, is to possibly run a query that would return only the 4
employee ID's, excluding the one passed in, and then create the
dynamic query string using an IN clause, with the 4 from the previous
query plus the one passed in.....

That would work.- Hide quoted text -

- Show quoted text -
You've provided a minimal example and no table definitions nor sample
data with which to work, and you expect a query to be magically
written to solve your issue. A basic stab will involve UNION unless
you will provide table DDL and data, so, seriously, if you want
assistance with this provide us the tools requested to begin the
task.


David Fitzjarrell


Reply With Quote
  #6  
Old   
Peter Nilsson
 
Posts: n/a

Default Re: SQL Statement - 02-24-2009 , 04:12 PM



mrdjmag... (AT) aol (DOT) com wrote:
Quote:
Can you have a select statement that returns a literal
AND normal query results without a UNION?

Say I have a parameter, like and employee ID, passed to
a procedure. I want to run a query which returns the top
4 records in the result set PLUS the values from the
employee ID passed in.......So, 5 records total.

The query is long, so I'm hoping to do it without a
UNION.......
Why? What have you got against UNION ALL?

--
Peter


Reply With Quote
  #7  
Old   
Michael Austin
 
Posts: n/a

Default Re: SQL Statement - 02-24-2009 , 07:45 PM



ddf wrote:
Quote:
On Feb 24, 3:28 pm, mrdjmag... (AT) aol (DOT) com wrote:
On Feb 24, 3:20 pm, ddf <orat... (AT) msn (DOT) com> wrote:





On Feb 24, 3:10 pm, mrdjmag... (AT) aol (DOT) com wrote:
Hello,
Can you have a select statement that returns a literal AND normal
query results without a UNION?
Say I have a parameter, like and employee ID, passed to a procedure.
I want to run a query which returns the top 4 records in the result
set PLUS the values from the employee ID passed in.......So, 5 records
total.
The query is long, so I'm hoping to do it without a UNION.......
Much Thanks
Provide an example of the output you want to see, as well as the table
definition and some sample data.
David Fitzjarrell
The other way, is to possibly run a query that would return only the 4
employee ID's, excluding the one passed in, and then create the
dynamic query string using an IN clause, with the 4 from the previous
query plus the one passed in.....

That would work.- Hide quoted text -

- Show quoted text -

You've provided a minimal example and no table definitions nor sample
data with which to work, and you expect a query to be magically
written to solve your issue. A basic stab will involve UNION unless
you will provide table DDL and data, so, seriously, if you want
assistance with this provide us the tools requested to begin the
task.


David Fitzjarrell

with something this generic and this simple - sounds like homework to
me. He doesn't even appear to know how spell the correct verb for
retrieving even the basics.

To the OP - Show us what you have tried and why you think it isn't working.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.