i want to calculate base on condition

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jack john
    New Member
    • Mar 2012
    • 1

    i want to calculate base on condition

    i have an quary
    select we.wip_entity_n ame job_number,
    wmt.transaction _date,
    bd.department_c ode,
    wmt.TRANSACTION _QUANTITY

    From wip_move_transa ctions wmt,
    wip_entities we,
    bom_departments bd


    where wmt.wip_entity_ id = we.wip_entity_i d
    AND wmt.organizatio n_id = we.organization _id
    AND wmt.fm_departme nt_id = bd.department_i d
    AND we.wip_entity_n ame = '24E/125914'

    output result is

    JOB_NUMBER TRANSACTION_DAT E DEPARTMENT_CODE TRANSACTION_QUA NTITY
    24E/125914 5/5/2011 17:36 FAB 14
    24E/125914 4/23/2011 15:35 FAB 10
    24E/125914 9/9/2011 12:35 FAB 1

    now i want to add parameter using TRANSACTION_dat e, if i will pass 5/5/2011 TRANSACTION_QUA NTITY will return sum of 10+14 = 24 according job_number
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    In your example quantity 14 is for date 4/23/2011 so why should it be returned?
    It looks like you need to select JOB_NUMBER, TRANSACTION_DAT E, sum(TRANSACTION _QUANTITY ) ...group by JOB_NUMBER, TRANSACTION_DAT E

    but watch out for those time parts in your database dates.

    Comment

    Working...