Jump to content

How to find total no. of records in a table having same info


shahnawaz

Recommended Posts

Hi,

 

i just want to find out total no. of records in a table which is having same information in some fields of that table mean matching information in the fields. i can elaborate it as suppose i have a survey table which is having 4 answers fields and there are thousands of records in that table, i want to know how many people have given same answers.

 

Please help me to write db query.

Thanks

 

It sounds like you can use "group by" for this.  Eg

 

SELECT a1, a2, a3, a4, count(*) FROM tab
GROUP BY a1, a2, a3, a4
HAVING count(*) > 1

 

That will give you a list of all sets of answers which appeared more than once in the table, and a count of each.  Is that what you want?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.