Results 1 to 2 of 2

Thread: SQL Help

  1. #1
    Join Date
    Feb 2004
    Posts
    24

    Unanswered: SQL Help

    Hi All,

    For this query I am getting the below error. This works in DB2 with the same syntax.
    Any help is appreciated.


    select avg(b.factor_Avg) as total_avg from
    (select a.cd_unamtn_factr_type,a.cd_amtn_per, a.rate_pc_cpn_amtn, a.dt_fundg_qtr, avg(a.rate_unam_factr) as factor_Avg
    from fas140_unam_factr a where
    a.cd_unamtn_factr_type = 1
    group by a.cd_unamtn_factr_type,a.cd_amtn_per, a.rate_pc_cpn_amtn, a.dt_fundg_qtr
    order by a.cd_amtn_per,a.rate_pc_cpn_amtn,a.dt_fundg_qtr) b

    Server Message: Number 156, Severity 15
    Incorrect syntax near the keyword 'select'.
    Server Message: Number 102, Severity 15
    Incorrect syntax near ')'.

    Thanks
    Srinivas
    Thanks
    Srinivas chityala

  2. #2
    Join Date
    Jun 2002
    Location
    Argentina
    Posts
    78
    Easy way:

    select a.cd_unamtn_factr_type,
    a.cd_amtn_per,
    a.rate_pc_cpn_amtn,
    a.dt_fundg_qtr,
    avg(a.rate_unam_factr) as factor_Avg
    into #temp
    from fas140_unam_factr a
    where a.cd_unamtn_factr_type = 1
    group by a.cd_unamtn_factr_type,
    a.cd_amtn_per,
    a.rate_pc_cpn_amtn,
    a.dt_fundg_qtr
    order by a.cd_amtn_per,
    a.rate_pc_cpn_amtn,
    a.dt_fundg_qtr

    select avg(b.factor_Avg) as total_avg
    from #temp


    or, I think this work too ?

    select avg(avg(a.rate_unam_factr)) as factor_Avg
    from fas140_unam_factr a
    where a.cd_unamtn_factr_type = 1
    group by a.cd_amtn_per,
    a.rate_pc_cpn_amtn,
    a.dt_fundg_qtr

    Bye bye

    Sebastian

Posting Permissions

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