SELECT * FROM ( SELECT FISNO,'2' AS FT,FISTURU,TARIH,1 AS FONT,MONTH(TARIH) AS AY,HESAP.ACIKLAMA AS HESAPADI, CONVERT(NVARCHAR(10),TARIH,104)+' '+FIS.FISNO+'  '+FIS.FISTURU AS A, HESAP.KODU,SUBSTRING(HESAP.KODU,1,3) AS ANAHESAP,(SELECT TOP 1 ACIKLAMA FROM HESAP WHERE KODU=SUBSTRING(HESAP.KODU,1,3)) AS ANAADI,HESAPISL.ACIKLAMA,HESAPISL.BORC,HESAPISL.ALACAK,FIS.YEVNO,CASE WHEN HESAPISL.BORC>0 THEN 1 ELSE 2 END AS BA FROM  ETS_HESAPISL AS HESAPISL,FIS,HESAP WHERE FIS.COUNTER=HESAPISL.FISCOUNTER AND HESAPISL.HESAPID=HESAP.HESAPID  AND FIS.SKODU='' AND FISTURU='TAHSIL' AND (HESAP.KODU BETWEEN '0000001' AND '9999999') AND (TARIH BETWEEN '01.01.2007' AND '12.31.2007')  UNION ALL  SELECT FISNO,'3' AS FT,FISTURU,TARIH,1 AS FONT,MONTH(TARIH) AS AY,HESAP.ACIKLAMA AS HESAPADI, CONVERT(NVARCHAR(10),TARIH,104)+' '+FIS.FISNO+'  '+FIS.FISTURU AS A, HESAP.KODU,SUBSTRING(HESAP.KODU,1,3) AS ANAHESAP,(SELECT TOP 1 ACIKLAMA FROM HESAP WHERE KODU=SUBSTRING(HESAP.KODU,1,3)) AS ANAADI,HESAPISL.ACIKLAMA,HESAPISL.BORC,HESAPISL.ALACAK,FIS.YEVNO,CASE WHEN HESAPISL.BORC>0 THEN 1 ELSE 2 END AS BA FROM  ETS_HESAPISL AS HESAPISL,FIS,HESAP WHERE FIS.COUNTER=HESAPISL.FISCOUNTER AND HESAPISL.HESAPID=HESAP.HESAPID  AND FIS.SKODU='' AND FISTURU='TEDIYE' AND (HESAP.KODU BETWEEN '0000001' AND '9999999') AND (TARIH BETWEEN '01.01.2007' AND '12.31.2007')  UNION ALL  SELECT FISNO,'4' AS FT,FISTURU,TARIH,1 AS FONT,MONTH(TARIH) AS AY,HESAP.ACIKLAMA AS HESAPADI, CONVERT(NVARCHAR(10),TARIH,104)+' '+FIS.FISNO+'  '+FIS.FISTURU AS A, HESAP.KODU,SUBSTRING(HESAP.KODU,1,3) AS ANAHESAP,(SELECT TOP 1 ACIKLAMA FROM HESAP WHERE KODU=SUBSTRING(HESAP.KODU,1,3)) AS ANAADI,HESAPISL.ACIKLAMA,HESAPISL.BORC,HESAPISL.ALACAK,FIS.YEVNO,CASE WHEN HESAPISL.BORC>0 THEN 1 ELSE 2 END AS BA FROM  ETS_HESAPISL AS HESAPISL,FIS,HESAP WHERE FIS.COUNTER=HESAPISL.FISCOUNTER AND HESAPISL.HESAPID=HESAP.HESAPID  AND FIS.SKODU='' AND FISTURU='MAHSUP' AND (HESAP.KODU BETWEEN '0000001' AND '9999999') AND (TARIH BETWEEN '01.01.2007' AND '12.31.2007') ) AS TBL ORDER BY TARIH,FT,FISNO
[Elektra                                                                                               ]

                                                         Y E V M İ Y E   D E F T E R İ

 YEVNO    TARİH      FİŞNO  FİŞTURU MAD.   KODU             HESAP ADI                  ACIKLAMA                               BORÇ        ALACAK
 -------- ------------------------- -----  ---------------- -------------------------- ------------------------------- ------------ -------------
{[^YEVNO] [A                      ] [># ]  [KODU          ] [HESAPADI                ] [ACIKLAMA                     ] [~2BORC:N   ] [~2ALACAK:N  ]}[TARIH:D   ]
