asdfsdf

Sql code posted
created at 26 Oct 11:04, updated at 29 Oct 14:42

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
select 
    i.invoice_pk,
    it.itemtype_pk,
    i.invoiceref_fk,
    case it.itemtype_pk
    when 1 then (select instruction_fk from item1details where item_pk=i.item_fk)
    when 2 then (select instruction_fk from item2details where item_pk=i.item_fk)
    when 3 then (select instruction_fk from item3details where item_pk=i.item_fk)
    when 6 then (select instruction_fk from item6details where item_pk=i.item_fk)
    when 7 then (select instruction_fk from item7details where item_pk=i.item_fk)
    when 15 then (select instruction_fk from item15details where item_pk=i.item_fk)
    else 1
    end as instruction
  from
    invoices i, itemtypes it
  where
    i.invoiceref_fk=@inv
    and i.itemtype_fk=it.itemtype_pk 
    and (i.rowstatus | it.rowstatus)=0
750 Bytes in 4 ms with coderay