calculation between 2 queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skhuon
    New Member
    • Oct 2006
    • 2

    calculation between 2 queries

    Query#1:
    select cd_fm_rgn_npl,
    sum(amt_ls_estd )as amt_ls_estd,
    sum(amt_ls_estd _in_mllns) as amt_ls_estd_in_ mllns
    from udbadm.mol_npl_ ls_hst
    where dt_rptg_per_npl = '08/31/2006'
    group by cd_fm_rgn_npl

    Query #2
    select cd_fm_rgn_npl,
    amt_ls_estd,
    amt_ls_estd_in_ mllns
    from udbadm.mol_npl_ ls_all_ppty_hst where cd_npl_ls_rpt_t ype = 3 and
    dt_rptg_per_npl = '08/31/2006' order by cd_fm_rgn_npl

    How do I do calculation between these two queries?
    I want to subtract sum(amt_ls_estd ) from query 1
    from amt_ls_estd from query 2.
  • bharad
    New Member
    • Aug 2006
    • 7

    #2
    Details are skimpy, can you provide more?

    Originally posted by skhuon
    Query#1:
    select cd_fm_rgn_npl,
    sum(amt_ls_estd )as amt_ls_estd,
    sum(amt_ls_estd _in_mllns) as amt_ls_estd_in_ mllns
    from udbadm.mol_npl_ ls_hst
    where dt_rptg_per_npl = '08/31/2006'
    group by cd_fm_rgn_npl

    Query #2
    select cd_fm_rgn_npl,
    amt_ls_estd,
    amt_ls_estd_in_ mllns
    from udbadm.mol_npl_ ls_all_ppty_hst where cd_npl_ls_rpt_t ype = 3 and
    dt_rptg_per_npl = '08/31/2006' order by cd_fm_rgn_npl

    How do I do calculation between these two queries?
    I want to subtract sum(amt_ls_estd ) from query 1
    from amt_ls_estd from query 2.

    Comment

    • masdi2t
      New Member
      • Jul 2006
      • 37

      #3
      u can solve ur problem using stored-procedure (only if u're using mysql5)

      Comment

      Working...