Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Location
    OFR, PT
    Posts
    16

    Unanswered: Subquery problem

    Hi,

    I have this query

    select
    (select sum(tot.tot_iliq) from martifer.totais_rec tot where cad_nre = nre
    and ano=2003 and mes=1) SJAN,
    (select sum(tot.tot_iliq) from martifer.totais_rec tot where cad_nre = nre
    and ano=2003 and mes=2) SFEV,
    (select sum(tot.tot_iliq) from martifer.totais_rec tot where cad_nre = nre
    and ano=2003 and mes=3) SMAR,
    [...]
    FROM martifer.cadastros
    where nre=797

    that works fine, but i would like to set the parameters "ano" and "mes" out of the subqueries, ie. in the main where. Is it possible?

    Help apreciated.

    Regards,
    Miguel

  2. #2
    Join Date
    Jul 2003
    Location
    Near Paris France
    Posts
    60
    No problem
    If you are using SQL+

    replace 2003 by &Ano
    1 by &mess1
    and so on

  3. #3
    Join Date
    Jul 2003
    Location
    OFR, PT
    Posts
    16
    Originally posted by pmscontact
    No problem
    If you are using SQL+

    replace 2003 by &Ano
    1 by &mess1
    and so on
    If i use it that way sql + keeps asking the parameter values for each subquery. And it seems these can't be assigned in the main where clause, wich would be really great.

    Regards,
    Miguel

  4. #4
    Join Date
    Jul 2003
    Location
    Near Paris France
    Posts
    60
    You can declare variable and feel them with parameter

    I Think it will be good

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •