2 Replies Latest reply on Apr 2, 2015 11:55 PM by rp0428

    sql question


      I have a sql like below. I am not able to use COLSUM for a calculation in the select clause as it gives me an error . Please assist with any alternatives.



      select t1.col2,

                (select SUM(t2.col3) as COL_SUM

                  from tab2 t2

                where t2.col1 = t1.col1

                and t2.col2 = t1.col2

                and t2.col3 between <date1> and <date2>


               (select COLSUM - SUM(t3.col3)

                    from tab3 t3

                where t3.col1 = t1.col1

                     and t3.col2 between <date1> and <date2>



      tab1 t1

      where t1.col1 =<col1>