Re: SQL Statement



On Feb 24, 3:28 pm, mrdjmag...@xxxxxxx wrote:
On Feb 24, 3:20 pm, ddf <orat...@xxxxxxx> wrote:





On Feb 24, 3:10 pm, mrdjmag...@xxxxxxx 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
.



Relevant Pages

  • Re: merge two tables in one queie
    ... Sorry, my mistake, I was using Union All. ... employee number Data Data1 ... You can build a UNION query. ... with the date is MicroDate and the Employee number is EmployeeNumber ...
    (microsoft.public.access.queries)
  • Re: merge two tables in one queie
    ... I was using UNION ALL. ... employee number Data Data1 ... You can build a UNION query. ... with the date is MicroDate and the Employee number is EmployeeNumber ...
    (microsoft.public.access.queries)
  • Re: Combining records from two queries
    ... combining UNION and SELECT queries to best effect. ... The list in each case has to have the same number & types of fields (for example, if the first Query begins with a Date/Time field, the second one should do so as well). ... I like to keep my Union Queries short and simple and do the rest of the work elsewhere. ... tblMentors comprises Subject Mentors and Professional Mentors and the Placement subform has a combo for each - the Subject Mentor combo puts the chosen MentorID in the SubjectMentorID field and the Professional Mentor combo puts the chosen MentorID in the ProfessionalMentorID field. ...
    (microsoft.public.access.queries)
  • Re: Aggregate calculations on calculated query fields?
    ... "KARL DEWEY" wrote: ... data entry date, display using datasheet form, and then a command button to ... query shown before to do all the calculations. ... UNION SELECT INVENTORY.Date ...
    (microsoft.public.access.queries)
  • RE: Mode Function in Access
    ... perhaps some sample data, I can write the query for you and try it against ... >> Select PrimaryKey, FieldData, countas Occurance from qrySource ...
    (microsoft.public.access.queries)