AdoQu.SQL.Text:='select max(fname)as Fname1, max(d1) as da1,max(va1) as v1,max(d2) as da2, max(va2) as v2, max(d3) as da3, max(va3) as v3 from'; AdoQu.SQL.Text:=AdoQu.SQL.Text+'(SELECT Opis.Код as OpID, Opis.fname as fname, da1.date_ as d1, da1.val as va1,da2.date_ as d2, da2.val as va2, da3.date_ as d3, da3.val as va3'; AdoQu.SQL.Text:=AdoQu.SQL.Text+'FROM data AS da1,data AS da2,data AS da3, Opis'; AdoQu.SQL.Text:=AdoQu.SQL.Text+'WHERE da1.name=opis.name And ((da1.date_='''+str3+''') xor (da1.date_=''0'')) and da2.name=opis.name And ((da2.date_='''+str2+''') xor (da2.date_=''0''))and da3.name=opis.name And ((da3.date_='''+str1+''') xor (da3.date_=''0'')) Order by opis.Код) where (d1 <> ''0'')or (d2 <> ''0'')or (d3 <> ''0'') Group by OPID Order by OpID'; AdoQu.Open; |