complex duplicate row
Posted in 2005
Topics: SQL Development & Query Writing
I have the following table create table "contav".f103 ( codc char(5), codfisc char(20), nrprezi integer, nrprezf integer, buc integer, taxa float, fel char(1), numeex char(50), adrex char(50), locex char(30), judex char(2), data date, timp datetime year to second, nrord serial not null constraint "contav".n308_126, regl char(1) ); It's there an SQL query to select the rows that are identical in all the columns, excepting codfisc (and nrord eventually, 'cause its serial) ?
adrian.baceanu@gmail.com wrote:
> I have the following table
>
> create table "contav".f103
> (
> codc char(5),
> codfisc char(20),
> nrprezi integer,
> nrprezf integer,
> buc integer,
> taxa float,
> fel char(1),
> numeex char(50),
> adrex char(50),
> locex char(30),
> judex char(2),
> data date,
> timp datetime year to second,
> nrord serial not null constraint "contav".n308_126,
> regl char(1)
> );
>
>
> It's there an SQL query to select the rows that are identical in all
> the columns, excepting codfisc (and nrord eventually, 'cause its
> serial) ?
>
How about:
select codc,
nrprezi,
nrprezf,
buc,
taxa,
fel,
numeex,
adrex,
locex,
judex,
data,
timp,
regl
from f103
group by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
having count(*) > 1
--
rh
Thanks... I think it's gonna work. I never thought how simple it could be. I'll us it to search if there are duplicate records, but distinct values of 'codfisc'.