|
xflekacm
Starting Member
2 Posts |
Posted - 2010-03-02 : 04:29:23
|
| HelloI need helpI have this question and this selectSELECT d.OZ + ' - ' + d.nazev OZ, s.MO_SIT + ' - ' + s.nazev mo_sit, o.nazev_firma + ' - ' + o.mesto_firma + ' - ' + o.ico firma, o.cislo + ' - ' + o.mesto + ' ,' + o.ULICE prodejna, o.ico_cislo, t.OBICIS as sortiment, SUM(ISNULL(f.PRODEJNI_CENA_CELKEM, 0)) cena, SUM(ISNULL(f.kusy, 0)) kusy from vystavene_faktury as fleft join odberatele as o on o.ico_cislo = f.ico_cislo left join sortiment as t on t.OBICIS = f.OBICISINNER JOIN DEALER AS d ON o.OZ1_ID = d.OZ_IDInner JOIN maloobchodni_sit AS s ON s.mosit_id = o.mosit_idWHERE f.DATUM_ZDAN_PLNENI between '2010-01-05' and '2010-01-06'AND f.DRUHPS = 'S' and f.obicis = '0072170030'Group by d.OZ, d.nazev, s.MO_SIT, s.nazev, o.nazev_firma, o.mesto_firma, o.ico, o.cislo, o.mesto, o.ULICE, o.ico_cislo, t.obicis....The select is failing to collect all the records from the table the company.................SELECT xx.OZ, xx.mo_sit, xx.firma, xx.prodejna, SUM(xx.cena) as cena, SUM(xx.kusy) as kusyFROM(SELECT x.OZ, x.mo_sit, x.firma, x.prodejna, SUM(ISNULL(f.PRODEJNI_CENA_CELKEM, 0)) cena, SUM(ISNULL(f.kusy, 0)) kusy FROM (SELECT d.OZ + ' - ' + d.nazev OZ, s.MO_SIT + ' - ' + s.nazev mo_sit, o.nazev_firma + ' - ' + o.mesto_firma + ' - ' + o.ico firma, o.cislo + ' - ' + o.mesto + ' ,' + o.ULICE prodejna, o.ico_cisloFROM odberatele AS o INNER JOIN DEALER AS d ON o.OZ1_ID = d.OZ_IDJOIN maloobchodni_sit AS s ON s.mosit_id = o.mosit_id GROUP BY d.OZ, d.nazev, s.MO_SIT, s.NAZEV, o.nazev_firma, o.mesto_firma, o.ico, o.cislo, o.mesto, o.ulice, o.ico_cislo ) AS xLEFT JOIN (SELECT f.DATUM_ZDAN_PLNENI, f.DRUHPS, f.ico_cislo, f.PRODEJNI_CENA_CELKEM, f.kusyFROM dbo.VYSTAVENE_FAKTURY AS f WHERE f.DATUM_ZDAN_PLNENI between '2010-01-05' and '2010-01-06'AND DRUHPS = 'S' and obicis = '0072170030') AS f ON f.ico_cislo = x.ico_cisloGROUP BY x.OZ, x.mo_sit, x.firma, x.prodejna) as xxGROUP BY xx.OZ, xx.mo_sit, xx.firma, xx.prodejnaThis selection selects While all firms but appears OBICIS.Please help. Thanks in advance |
|