-1

Running the below query, the column t.idsupplier is not known

    select
      t.po_nomor
      , p.nama_supplier
      , p1.nama_barang
      , t.total
    from (select
            t1.po_nomor
            , (sum(t1.jumlah)-coalesce(t4.terima,0)) as total
          from pengiriman_supply t1
          inner join data_supplier t2 on t1.idsupplier = t2.id_supplier
          inner join data_barang t3 on t1.idbarang = t3.idbarang
          left join masuk t4 on t4.refrence = t1.po_nomor
          where t1.tanggal between date_sub(curdate(), interval 120 day) and curdate()
          group by t1.po_nomor) t
    inner join data_supplier p on t.idsupplier = p.id_supplier
    inner join data_barang p1 on t.idbarang = p1.idbarang
    order by t.po_nomor desc;

1 Answer 1

3

t is the alias for

select
  t1.po_nomor
  , (sum(t1.jumlah)-coalesce(t4.terima,0)) as total
from pengiriman_supply t1
inner join data_supplier t2 on t1.idsupplier = t2.id_supplier
inner join data_barang t3 on t1.idbarang = t3.idbarang
left join masuk t4 on t4.refrence = t1.po_nomor
where t1.tanggal between date_sub(curdate(), interval 120 day) and curdate()

As the outer select includes t.po_nomor you probably forgot to include the column idsupplier.

Please comment, if and as this requires adjustment / further detail.

Not the answer you're looking for? Browse other questions tagged or ask your own question.