22,300
社区成员




SELECT DISTINCT Top (100) Percent rd.cell_index,rd.freq_id,rd.data_range_id,rd.org_id,convert(float,rd.curr_term_value) AS curr_term_value, rd.cur_id ,rd.rept_year,rd.rept_month,rd.template_id,rd.version_id, rd.[status],rd.row_id, rd.col_id,dbo.ReplaceX( ci.cell_cn_name,' | 本外币合计') as cell_cn_name,ci.cell_cn_name as cell_cn_name2
FROM report_data rd INNER JOIN cell_info ci ON rd.cell_index=ci.cell_index AND rd.template_id='G0100' AND rd.version_id = (select max(version_id) from template_info where template_id='G0100' and convert(varchar(10),start_date,102)<=convert(varchar(10),dbo.getdatew(2011,1),102)
and convert(varchar(10),dbo.getdatew(2011,1),102)<=convert(varchar(10),end_date,102))
AND ci.col_id = 'F' AND ci.row_id>=(SELECT MAX(row_id)
FROM cell_info ci WHERE ci.cell_index='G01000690F6' AND ci.version_id=(select max(version_id) from template_info where template_id='G0100'
and convert(varchar(10),start_date,102)<=convert(varchar(10),dbo.getdatew(2011,1),102)
and convert(varchar(10),dbo.getdatew(2011,1),102)<=convert(varchar(10),end_date,102)))
AND ci.row_id<(select max(row_id) from cell_info where cell_index='G01000690F62' and version_id=
(select max(version_id) from template_info where template_id='G0100'
and convert(varchar(10),start_date,102)<=convert(varchar(10),dbo.getdatew(2011,1),102)
and convert(varchar(10),dbo.getdatew(2011,1),102)<=convert(varchar(10),end_date,102)))
AND ci.cell_cn_name NOT LIKE '%[0-9].[0-9]%'
AND rd.rept_year=2011 AND rd.rept_month=1 AND rd.data_range_id=1
AND rd.org_id='F104H101520301001'
select row_number()over(order by tb.curr_term_value desc) as rownum,tb.cell_cn_name from (
SELECT DISTINCT Top (100) Percent rd.cell_index,rd.freq_id,rd.data_range_id,rd.org_id,convert(float,rd.curr_term_value) AS curr_term_value, rd.cur_id ,rd.rept_year,rd.rept_month,rd.template_id,rd.version_id, rd.[status],rd.row_id, rd.col_id,dbo.ReplaceX( ci.cell_cn_name,' | 本外币合计') as cell_cn_name,ci.cell_cn_name as cell_cn_name2
FROM report_data rd INNER JOIN cell_info ci ON rd.cell_index=ci.cell_index AND rd.template_id='G0100' AND rd.version_id = (select max(version_id) from template_info where template_id='G0100' and convert(varchar(10),start_date,102)<=convert(varchar(10),dbo.getdatew(2011,1),102)
and convert(varchar(10),dbo.getdatew(2011,1),102)<=convert(varchar(10),end_date,102))
AND ci.col_id = 'F' AND ci.row_id>=(SELECT MAX(row_id)
FROM cell_info ci WHERE ci.cell_index='G01000690F6' AND ci.version_id=(select max(version_id) from template_info where template_id='G0100'
and convert(varchar(10),start_date,102)<=convert(varchar(10),dbo.getdatew(2011,1),102)
and convert(varchar(10),dbo.getdatew(2011,1),102)<=convert(varchar(10),end_date,102)))
AND ci.row_id<(select max(row_id) from cell_info where cell_index='G01000690F62' and version_id=
(select max(version_id) from template_info where template_id='G0100'
and convert(varchar(10),start_date,102)<=convert(varchar(10),dbo.getdatew(2011,1),102)
and convert(varchar(10),dbo.getdatew(2011,1),102)<=convert(varchar(10),end_date,102)))
AND ci.cell_cn_name NOT LIKE '%[0-9].[0-9]%'
AND rd.rept_year=2011 AND rd.rept_month=1 AND rd.data_range_id=1
AND rd.org_id='F104H101520301001') tb
where ......