با سلام
با تشکر از توجه خاص جناب آقای کوشا ، در کپی and جا افتاده بود . بازهم خطا مشهود میباشد
البته وقتی از ((ور)) محدوده بین تاریخ را حذف میکنیم درست است. آیا روشی دیگر برای اینجا میتوان بیان کرد که محدوده تاریخ را حساب کند به اضافه شرطهای دیگر...
با روش پارامتر نمیدونم چرا خطا میدهد .
آخرین کد من:
adoQuery1.SQL.Clear;
adoQuery1.SQL.Add('select count(no),count(case when(status=''cancel'') then status else null end),sum(time1),sum(time2),sum(time3)'+
',count(case when(doreyi=''ÏÇÑÏ'') then doreyi else null end ),count(case when(status=''cancel'' and doreyi=''ÏÇÑÏ'') then status else null end)'+
',sum(case when(time1>0 and doreyi=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time2>0 and doreyi=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time3>0 and doreyi=''ÏÇÑÏ'' ) then time1 else null end)'+
',count(case when(pm=''ÏÇÑÏ'') then doreyi else null end ),count(case when(status=''cancel'' and pm=''ÏÇÑÏ'') then status else null end)'+
',sum(case when(time1>0 and pm=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time2>0 and pm=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time3>0 and pm=''ÏÇÑÏ'' ) then time1 else null end)from permit_all');
adoQuery1.SQL.Add('WHERE unit like '+QuotedStr('%'+ComboBox1.text+'%')+ ' and '+ ' amaliat like '+QuotedStr('mec')+
' and ' + 'date_ss BETWEEN :Date1 AND :Date2');
adoQuery1.Parameters.ParamByName('Date1').Value:= shdatetostr(exShDatePicker1.Date);
adoQuery1.Parameters.ParamByName('Date2').Value:= shdatetostr(exShDatePicker2.Date);
adoQuery1.Open;
adoQuery1.SQL.Add('union all');
adoQuery1.SQL.Add('select count(no),count(case when(status=''cancel'') then status else null end),sum(time1),sum(time2),sum(time3)'+
',count(case when(doreyi=''ÏÇÑÏ'') then doreyi else null end ),count(case when(status=''cancel'' and doreyi=''ÏÇÑÏ'') then status else null end)'+
',sum(case when(time1>0 and doreyi=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time2>0 and doreyi=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time3>0 and doreyi=''ÏÇÑÏ'' ) then time1 else null end)'+
',count(case when(pm=''ÏÇÑÏ'') then doreyi else null end ),count(case when(status=''cancel'' and pm=''ÏÇÑÏ'') then status else null end)'+
',sum(case when(time1>0 and pm=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time2>0 and pm=''ÏÇÑÏ'' ) then time1 else null end)'+
',sum(case when(time3>0 and pm=''ÏÇÑÏ'' ) then time1 else null end)from permit_all');
adoQuery1.SQL.Add('WHERE unit like '+QuotedStr('%'+ComboBox1.text+'%')+ ' and '+ ' amaliat like '+QuotedStr('mec')+
' and '+ 'date_ss BETWEEN :Date1 AND :Date2');
adoQuery1.Parameters.ParamByName('Date1').Value:= shdatetostr(exShDatePicker1.Date);
adoQuery1.Parameters.ParamByName('Date2').Value:= shdatetostr(exShDatePicker2.Date);
adoQuery1.Open;
باتشکر از همه دوستان.
داود