求教,我在sql 2000能用的语句,转换到delphi里面,引号什么怎么处理,用adoquery.text:=''l老是报错
帮我看看~~谢谢
insert into export(id,nf,yf,byds,sgds,bj)select e.remote_id as id,year('2012-11-13') as nf,month('2012-11-13') as yf,e.readdata as byds,'0','N' from readdata as e inner join(select distinct a.xiaoqu_name ,a.remote_id as remote_id,max(b.readtime) as readtime from user_data as a inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='EV2双月16_20日' and b. readtime>'2012-11-07' and b.readtime < '2012-11-14' group by a.xiaoqu_name,a.remote_id ) as f on e.remote_id=f.remote_id and e.readtime=f.readtime order by substring(f.remote_id,1,6),substring(f.remote_id,7,2),substring(f.remote_id,9,2)
insert into export(id,nf,yf,byds,sgds,bj)select e.remote_id as id,year('2012-11-13') as nf,month('2012-11-13') as yf,e.readdata as byds,'0','N' from readdata as e inner join(select distinct a.xiaoqu_name ,a.remote_id as remote_id,max(b.readtime) as readtime from user_data as a inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='EV2双月16_20日' and b. readtime>'2012-11-07' and b.readtime < '2012-11-14' group by a.xiaoqu_name,a.remote_id ) as f on e.remote_id=f.remote_id and e.readtime=f.readtime order by substring(f.remote_id,1,6),substring(f.remote_id,7,2),substring(f.remote_id,9,2)
+ ' INNER JOIN'
+ ' (SELECT DISTINCT A.XIAOQU_NAME, A.REMOTE_ID AS REMOTE_ID,'
+ ' MAX (B.READTIME) AS READTIME'
+ ' FROM USER_DATA AS A INNER JOIN READDATA AS B'
+ ' ON A.REMOTE_ID = B.REMOTE_ID'
+ ' AND A.SELINFO = ''EV2双月16_20日'''
+ ' AND B.READTIME > ''2012-11-07'''
+ ' AND B.READTIME < ''2012-11-14'''
+ ' GROUP BY A.XIAOQU_NAME, A.REMOTE_ID) AS F'
+ ' ON E.REMOTE_ID = F.REMOTE_ID AND E.READTIME = F.READTIME'
+ ' ORDER BY SUBSTRING (F.REMOTE_ID, 1, 6),'
+ ' SUBSTRING (F.REMOTE_ID, 7, 2),'
+ ' SUBSTRING (F.REMOTE_ID, 9, 2)';
[其他解释]
ADOQuery1.Close;
ADOQuery1.SQL.Text:=
'insert into export(id,nf,yf,byds,sgds,bj)select e.remote_id as id,year('
+QuotedStr('2012-11-13')
+') as nf,month('
+QuotedStr('2012-11-13')
+') as yf,e.readdata as byds,'
+QuotedStr('0')
+','
+QuotedStr('N')
+' from readdata as e inner join(select distinct a.xiaoqu_name ,'
+'a.remote_id as remote_id,max(b.readtime) as readtime from user_data as a'
+' inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='
+QuotedStr('EV2双月16_20日')
+' and b. readtime>'
+QuotedStr('2012-11-07')
+' and b.readtime < '
+QuotedStr('2012-11-14')
+' group by a.xiaoqu_name,a.remote_id ) as f on e.remote_id=f.remote_id and '
+'e.readtime=f.readtime order by substring(f.remote_id,1,6),'
+'substring(f.remote_id,7,2),substring(f.remote_id,9,2)';
ADOQuery1.ExecSQL;