SQL>select a.col_1,b.col_2,b.col_3... SQL>from (select distinct col_1 from table_name) a,table_name b SQL>a.col_1=b.col_1;
所有列都查,那就得进行分组,假设两列: SELECT DISTINCT A1,A2 FROM TABLE GROUP BY A1,A2
select * from dual a where a.rowid = (select rowid from dual b where b.colname = a.colname and rownum = 1)
SELECT A1,A2 FROM TABLE GROUP BY A1,A2
create or replace pro is vrow tab%rowtype; cursor curb(va tab.col%type) is select * from tab; cursor cura is select distinct col from tab; begin for curarec in cura loop open curb(curarec.col); fetch curb into vrow; close curb; dbms_output.put_line(vrow.col-1||vrow.col-2||.......||vrow.col-n); end loop; end pro; 我不知道当某列有重复值
SQL>from (select distinct col_1 from table_name) a,table_name b
SQL>a.col_1=b.col_1;
SELECT DISTINCT A1,A2 FROM TABLE GROUP BY A1,A2
is
vrow tab%rowtype;
cursor curb(va tab.col%type) is select * from tab;
cursor cura is select distinct col from tab;
begin
for curarec in cura loop
open curb(curarec.col);
fetch curb into vrow;
close curb;
dbms_output.put_line(vrow.col-1||vrow.col-2||.......||vrow.col-n);
end loop;
end pro;
我不知道当某列有重复值
而且,你应该用rpad()函数使显示更加象报表