SELECT * FROM (
    SELECT 
        COALESCE (
            (SELECT COALESCE (sum(irskal.anamiktar), 0)  
                * (SELECT 
                    birim.fiyat2 * (SELECT kur1 
                                    FROM sis_doviz_kuru kur 
                                    WHERE birim._key_sis_doviz2 = kur._key_sis_doviz 
                                    ORDER BY tarih desc 
                                    LIMIT 1)
                    FROM scf_stokkart_birimleri birim
                    WHERE _key_scf_stokkart = stok._key
                    AND anabirim = '1'
                  )
                 FROM scf_irsaliye irs, scf_irsaliye_kalemi irskal
                 WHERE irskal._key_kalemturu = stok._key
                 AND irskal._key_scf_irsaliye = irs._key
                 AND irs.karsifirma = 'KENDI'
                 AND (irs.turu='MAI' OR irs.turu='KGI' OR irs.turu='PS' OR irs.turu='TS' OR irs.turu='KC' OR irs.turu='KCO')
                 AND ( irs._key_sis_depo_dest = '$$$$0000003l$1$$'  OR  irs._key_sis_depo_dest = '$$$$00000048$1$$'  OR  irs._key_sis_depo_dest = '$$$$0000004b$1$$'  OR  irs._key_sis_depo_dest = '$$$$0000004d$1$$' )
                 AND ((irskal._key LIKE '0000%' OR irskal._key LIKE '0101%' OR irskal._key LIKE '$$%'))
                 AND irs.tarih <= '2005-08-26'
            ), 0
        ) as arti_fiili_irs_karsifirma,
        stok.*
        FROM scf_stokkart stok
) AS _SWT WHERE (_key LIKE '00%' OR _key LIKE '01%' OR _key LIKE '$$%') ORDER BY _key desc
