SELECT ANART00F.ACODAR AS CODICE,ANART00F.ACODFO AS CODICEFOR,ANART00F.ACODTE AS CODICETEC, ANART00F.ACODFO as FORNART, ANART00F.ACODLI, ANART00F.ACLASS,ANART00F.AFAMIG,ANART00F.AGRUPP, ANART00F.AUM AS UM, ANART00F.AEOP, ANART00F.ACFIMB,ISNULL(ANART00F.AIVA,0) as AIVA, ANARWEB.AYTUBE, ANARWEB.ADESCEST, ISNULL(FAMIL00F.FLDEAR,FAMIG00F.FDESFA) AS FAMIGLIA, ISNULL(ANART00F.APRZNT,0) AS PREZZO, ISNULL(ANART00F.APRZLO,0) AS PREZZOLORDO, CASE INTORD0F.IDPRZF WHEN 'Y' THEN ISNULL(INTORD0F.IDPREZ,0) ELSE 0 END AS PREZZOFORZATO, CASE INTORD0F.IDPRZF WHEN 'Y' THEN 1 ELSE 0 END AS ISPREZZOFORZATO, ANART00F.ASCVE1,ANART00F.ASCVE2,ANART00F.ASCVE3,ANART00F.APRZC1,ANART00F.ASCVC1,ANART00F.AVALD1,ANART00F.AVALA1,ANART00F.APRZC2,ANART00F.ASCVC2,ANART00F.AVALD2,ANART00F.AVALA2,ANART00F.APRZC3,ANART00F.ASCVC3,ANART00F.AVALD3,ANART00F.AVALA3,ANART00F.APRZC4,ANART00F.ASCVC4,ANART00F.AVALD4,ANART00F.AVALA4,ANART00F.APRZC5,ANART00F.ASCVC5,ANART00F.AVALD5,ANART00F.AVALA5,CATVE0F.CCODAR,CATVE0F.CPREZZ,CATVE0F.CSCON1,CATVE0F.CSCON2,CATVE0F.CPRZNT,LISTIN00F.LPRZL1,LISTIN00F.LSC1L1,LSC2L1,LISTIN00F.LPRZN1,LISTIN00F.LPRZL2,LISTIN00F.LSC1L2,LSC2L2,LISTIN00F.LPRZN2,LISTIN00F.LPRZL3,LISTIN00F.LSC1L3,LSC2L3,LISTIN00F.LPRZN3,LISTIN00F.LPRZL4,LISTIN00F.LSC1L4,LSC2L4,LISTIN00F.LPRZN4,LISTIN00F.LPRZL5,LISTIN00F.LSC1L5,LSC2L5,LISTIN00F.LPRZN5,LISTIN00F.LPRZL6,LISTIN00F.LSC1L6,LSC2L6,LISTIN00F.LPRZN6,LISTIN00F.LPRZL7,LISTIN00F.LSC1L7,LSC2L7,LISTIN00F.LPRZN7,LISTIN00F.LPRZL8,LISTIN00F.LSC1L8,LSC2L8,LISTIN00F.LPRZN8,LISTIN00F.LPRZL9,LISTIN00F.LSC1L9,LSC2L9,LISTIN00F.LPRZN9,isNull(ANARL00F.ALDEAR,ANART00F.ADESAR) AS DESCRIZIONE,ANART00F.AUM,ANART00F.AFLPR5 AS PROMONEWS, EINTES00F.EIGIAC-EINTES00F.EIORDC AS GIACENZA, ANART00F.AGIACE AS GIACENZA_ORIG, ISNULL(ANARWEB.ASALDO,0) as INSALDO, INTORD0F.IDNORI AS CARRELLO, ANART00F.ACAR01, ANART00F.ACAR02, ANART00F.ACAR03, ANART00F.ACAR04, ANART00F.ACAR05, ANART00F.ACAR06, ANART00F.ACAR07, ANART00F.ACAR08, ANART00F.ACAR09, ANART00F.ACAR10, ANART00F.ACAR11, ANART00F.ACAR12, ANART00F.ACAR13, ANART00F.ACAR14, ANART00F.ACAR15, ANART00F.ACAR16, ANART00F.ACAR17, ANART00F.ACAR18, ANART00F.ACAR19, ANART00F.ACAR20, ANART00F.ACODLI, ANADEPRZ FROM ANART00F LEFT JOIN CATVE0F ON ANART00F.ACODAR=CATVE0F.CCODAR AND CATVE0F.CDATDD<=20191115 AND CATVE0F.CDATDA>=20191115 AND CCODCA=(SELECT TOP 1 CCODCA FROM CATVE0F CAT2 WHERE CATVE0F.CCODAR=CAT2.CCODAR AND CAT2.CDATDD<=20191115 AND CAT2.CDATDA>=20191115) LEFT JOIN LISTIN00F ON ANART00F.ACODAR=LISTIN00F.LCOART LEFT JOIN FAMIG00F ON ANART00F.AFAMIG=FAMIG00F.FCODIC LEFT JOIN FAMIL00F ON FAMIG00F.FCODIC=FAMIL00F.FLCDFA AND FAMIL00F.FLLING='' LEFT JOIN ANARL00F ON ANART00F.ACODAR=ANARL00F.ALCDAR AND ANARL00F.ALLING='' LEFT JOIN CLASS00F ON ANART00F.ACLASS=CLASS00F.CCODIC AND ANART00F.AGRUPP=CLASS00F.CRGRUP LEFT JOIN EINTES00F ON ANART00F.ACODAR=EINTES00F.EICART LEFT JOIN ANARWEB ON ANART00F.ACODAR=ANARWEB.ACODAR LEFT JOIN DESAR00F ON (DESAR00F.CARTIC=ANARWEB.ACODAR AND DESAR00F.CLINGU='' AND DESAR00F.CRIGAA=1) LEFT JOIN INTORD0F ON ANART00F.ACODAR=INTORD0F.IDARTI AND INTORD0F.IDNORI=0 WHERE (ANART00F.AFLPR5='P' OR (ANART00F.AVALD1<=20191115 AND ANART00F.AVALA1>=20191115) OR (ANART00F.AVALD2<=20191115 AND ANART00F.AVALA2>=20191115) OR (ANART00F.AVALD3<=20191115 AND ANART00F.AVALA3>=20191115) OR (ANART00F.AVALD4<=20191115 AND ANART00F.AVALA4>=20191115) OR (ANART00F.AVALD5<=20191115 AND ANART00F.AVALA5>=20191115)) WHERE (ANART00F.AARINT='Y' AND (ANART00F.AFLPR2='C' or ANART00F.AFLPR2='A') AND (ANART00F.ACODLI='' or ANART00F.ACODLI=ANART00F.ACODAR or ANART00F.ACODLI is null)) ORDER BY AEVIDE DESC, DESCRIZIONE