Showing posts with label fld2. Show all posts
Showing posts with label fld2. Show all posts

Wednesday, March 21, 2012

query to show duplicates

mytable fld1 int primkey
fld2 varchar(20),
fld3 varchar(20)
From the definition of the above table, how do i do i modify my below query to only select the rows with duplicates in fld2. I know a groupby with a having count will display the duplicates for a given field, but i want my query to see all the fields and rows that are duplicates.
select fld1, fld2, fld3 from mytable
SELECT fld2,COUNT(*) FROM myTable GROUP BY Flt2 HAVING COUNT(*)>1

Wednesday, March 7, 2012

Query to be resolved

Hi,
if anybody can reslove this sql query :
Fld1 Fld2
=== =====
1 100
1 200
2 400
2 401
2 402
=================
I tried but cud not suceed to bring this output :
fld1 fld2
===============
1 100
2 400
I think i could put forward my question clearly...pls try if anybody can
resolve it.
Thanks in advance.......
GDTry,
select fld1, min(fld2) as min_fld2
from t1
group by gld1
go
AMB
"Dubey Gopal" wrote:

> Hi,
> if anybody can reslove this sql query :
> Fld1 Fld2
> === =====
> 1 100
> 1 200
> 2 400
> 2 401
> 2 402
> =================
> I tried but cud not suceed to bring this output :
> fld1 fld2
> ===============
> 1 100
> 2 400
> I think i could put forward my question clearly...pls try if anybody can
> resolve it.
> Thanks in advance.......
> GD
>|||Thanks AMB...It is working fine !!
GD
"Alejandro Mesa" wrote:
> Try,
> select fld1, min(fld2) as min_fld2
> from t1
> group by gld1
> go
>
> AMB
> "Dubey Gopal" wrote:
>