Home » SQL & PL/SQL » SQL & PL/SQL » How I avoid the duplicate record and show only one record for every etudend from query
How I avoid the duplicate record and show only one record for every etudend from query [message #183863] Mon, 24 July 2006 03:33 Go to next message
mfa786
Messages: 210
Registered: February 2006
Location: karachi
Senior Member
hi master
Sir
I have many duplicate record in my table

I use this query

STDCODE COUNT(*)
-------------------- ----------------------
021-00-11133 1
021-00-11327 1
021-00-11329 2
021-00-11400 3
021-00-11401 1
021-00-11473 2
021-00-11490 1
021-00-11498 2
021-00-11521 1
021-00-11529 2
021-00-11531 2
021-00-11535 1
021-00-11548 1
021-00-11558 2

But sir I need only one record for every student
Such as


STDCODE COUNT(*)
-------------------- ----------------------
021-00-11133 1
021-00-11327 1
021-00-11329 1
021-00-11400 1
021-00-11401 1
021-00-11473 1
021-00-11490 1
021-00-11498 1
021-00-11521 1
021-00-11529 1
021-00-11531 1
021-00-11535 1
021-00-11548 1
021-00-11558 1

And in last total student

How I avoid the duplicate record and show only one record for every etudend from query
Please give me idea

Thank




Re: How I avoid the duplicate record and show only one record for every etudend from query [message #183865 is a reply to message #183863] Mon, 24 July 2006 03:35 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
What did the search show you?
What have you tried so far?
What is unclear about the FAQ page?

MHE
Re: How I avoid the duplicate record and show only one record for every etudend from query [message #183889 is a reply to message #183863] Mon, 24 July 2006 04:48 Go to previous messageGo to next message
vin_odks
Messages: 153
Registered: July 2006
Location: -
Senior Member
Hi,

use Group by clause and always try before posting....


Regards



Re: How I avoid the duplicate record and show only one record for every etudend from query [message #183902 is a reply to message #183889] Mon, 24 July 2006 05:28 Go to previous message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
COUNT is an aggregate function and can not be used without GROUP BY clause (unless it is the only element of the SELECT column list). Therefore, I guess that OP used GROUP BY; statement he used was something like this:

SELECT stdcode, COUNT(*) FROM some_table GROUP BY stdcode;

In order to get a single value for each student, either remove duplicates from the table, or, for example,

SELECT DISTINCT stdcode FROM some_table;
Previous Topic: how to encrypt and store the password?
Next Topic: help with pl/sql code
Goto Forum:
  


Current Time: Sat Dec 03 22:39:55 CST 2016

Total time taken to generate the page: 0.08503 seconds