select [YLCh_Symbol_Charakterystyka], isnull( [YLCh_Ilosc], 0) from [dbo].[YLokal_Charakterystyka] where YLCh_IdLokal = ^ylo:id|macro^
select 'L->' + YLKR_Symbol_KluczRozliczenie, YLKW_Kwota from YLokal_Klucz_Rozliczenie, YLokal_Klucz_Wartosc where YLKR_IdLokal = ^ylo:id|macro^ and YLKW_Id = YLKR_IdLokalKluczWartosc union select 'N->' + YNKR_Symbol_KluczRozliczenie, YNKW_Kwota from YLokal, YNieruchomosc_Klucz_Rozliczenie, YNieruchomosc_Klucz_Wartosc where YLO_Id = ^ylo:id|macro^ and YLO_IdNieruchomosc = YNKR_IdNieruchomosc and YNKR_IdNieruchomoscKluczWartosc = YNKW_Id union select 'Z->' + YZKR_Symbol_KluczRozliczenie, YZKW_Kwota from YLokal, YNieruchomosc, YZarzadca_Klucz_Rozliczenie, YZarzadca_Klucz_Wartosc where YLO_Id = ^ylo:id|macro^ and YLO_IdNieruchomosc = YN_Id and YN_IdZarzadca = YZKR_IdZarzadca and YZKR_IdZarzadcaKluczWartosc = YZKW_Id
select 'Saldo należności:', IsNull( (select Sum( YNN_DoZaplaty) from YNaleznosc where YNN_Kontrahent = YKO_Akronim ) -(select Sum( YZN_DoZaplaty) from YZobowiazanie where YZN_Kontrahent = YKO_Akronim), 0) from YLokal, YKontrahent where YLO_Id = ^ylo:id|macro^ and YLO_IdKontrahent = YKO_Id
select RTrim( YNN_NrDok)+' (-)', YNN_DoZaplaty from YLokal, YKontrahent, YNaleznosc where YLO_Id = ^ylo:id|macro^ and YLO_IdKontrahent = YKO_Id and YNN_Kontrahent = YKO_Akronim and IsNull( YNN_DoZaplaty, 0) <> 0 union all select RTrim( YZN_NrDok) + ' (+)', YZN_DoZaplaty from YLokal, YKontrahent, YZobowiazanie where YLO_Id = ^ylo:id|macro^ and YLO_IdKontrahent = YKO_Id and YZN_Kontrahent = YKO_Akronim and IsNull( YZN_DoZaplaty, 0) <> 0 union all select 'Saldo: ', IsNull( (select Sum( YNN_DoZaplaty) from YNaleznosc where YNN_Kontrahent = YKO_Akronim ) -(select Sum( YZN_DoZaplaty) from YZobowiazanie where YZN_Kontrahent = YKO_Akronim), 0) from YLokal, YKontrahent where YLO_Id = ^ylo:id|macro^ and YLO_IdKontrahent = YKO_Id
select YESC_Grupa, LTrim( Str( Sum( Round(B.YKNC_Ilosc*B.YKNC_Cena, 2)), 12, 2)) from YKartoteka_NC_Lokal A, YKartoteka_NC_Lokal B, YElement_Skladnik_Czynsz where A.YKNC_Id = ^yknc:id|macro^ and A.YKNC_Rok = B.YKNC_Rok and A.YKNC_Mc = B.YKNC_Mc and A.YKNC_IdLokal = B.YKNC_IdLokal and B.YKNC_IdElement_Skladnik_Czynsz = YESC_Id group by YESC_Grupa order by YESC_Grupa