DansTonCode.net
quote.smartness() == 42Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.@author Brian W. Kernighan
Quote #140
sql
@
author 
igoooor
0
SELECT k.nzw1 as kontrahent, d.ndok||d.nrdk as numer_dok, d.dtsp as data, k.nakw, d.sndk as wartosc_netto,
               ( SELECT sum(p.cnsp*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr ) asx   
                 wartosc_netto_sp, 
                ( SELECT sum( (p.cnsp-p.ppr_cnzn)*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr ) 
                as marza, 
                ( SELECT count(dd.ndrz) FROM drz dd WHERE dd.nknt_dla=k.nknt and dd.dtsp<&#39;2012-06-01&#39; ) as ile_dok, 
                ( SELECT sum(p.cnsp*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr AND t.anmr is 
                  not null ) as wartosc_netto_sp_leki, 
                ( SELECT sum( (p.cnsp-p.ppr_cnzn)*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr 
                  AND t.anmr is not null ) as marza_leki, 
                ( SELECT sum(p.cnsp*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr AND t.anmr is 
                   null AND t.npst=4) as wartosc_netto_sp_zoo, 
                 ( SELECT sum( (p.cnsp-p.ppr_cnzn)*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr 
                   AND t.anmr is null AND t.npst=4) as marza_zoo, 
                 ( SELECT sum(p.cnsp*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr AND t.anmr is 
                    null AND t.npst<>4) as wartosc_netto_sp_poz, 
                 ( SELECT sum( (p.cnsp-p.ppr_cnzn)*p.ilsp) FROM pro p,twr t WHERE p.ndrz=d.ndrz AND p.ntwr=t.ntwr 
                  AND t.anmr is null AND t.npst<>4) as marza_poz,
                   d.ndrz as id_dok, k.nknt as id_kontrah, d.uwg2 as uwagi, d.sbdk as wartosc_brutto, d.opis 
FROM DRZ d,knt k WHERE d.nknt_dla=k.nknt AND d.rezr<>&#39;T&#39; AND d.nrdk<>&#39;-&#39; AND to_date(d.dtsp,&#39;YYYY-MM-DD&#39;) between &#39;2012-07-01&#39; and &#39;2012-07-15&#39; and k.nknt in (4103,6433,5980,6504,6440,6442,6426,6652,6161,6431,6675,6598,5868,6493,6132,6162,6668,6457,5979,6577,6622,6456,6235,6643,6087,5982,7242,7264,7402,7676,7802,7865,7986,8354,8824,6985,6818,6078,9618,9706,9824,9913,9953,10013,10167,10418,10556,10601,10832,11011,11156,11201,11355,11384,11577,12039,12100,12156,6966,12421,12270,12243,12609,6304,12683,12745,12506,13021,5969,6462,5976,12939,12679,5963,12460,10629,12345,12429,11256,12752,12790,13050,12185,10155,13031,12436,12966,12801,13047) ORDER BY d.dtsp,d.ndok
Code source n°140
Code-source en sql proposé par igoooor
 
 0