|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
finding duplicates
I'm looking for some help with something pretty basic here and was wondering if anyone could maybe help me.
I have a transactions table - horse racing tips - that holds amongst other things, a number of values, each of which is the primary key to another table e.g. it holds the primary key ids for jockeys, courses etc. on a lookup basis. I'm trying to find out which one occurs the most number of times and also which one occurs the least so that I can display some basis stats for visitors. So for example, if the horse with ID number 26 has been selected 10 times and horse number 22 has been selected 12 times and horse number 1 has been selected only once, I'd like to be able to show that the top selection is number 22 with 12 selections and the bottom selection number 1 with 1 selection. I'm sure there must be some quick and easy way to do this rather than having to sit and cut a whole lot of clumsy code. Anyone any ideas? I hope this makes sense! |
|
#2
|
||||
|
||||
|
RE: finding duplicates
make the selected_times as an alias, then ORDER BY that alias. Sample:
SELECT *, selected_time as sel_time FROM table WHERE field=condition GROUP BY horse_id ORDER BY sel_time |
|
#3
|
|||
|
|||
|
RE: finding duplicates
Thanks. I've gone for the following
SELECT pid, count(*) as sel_time FROM todaystip WHERE outcome = "won" GROUP BY pid ORDER BY sel_time DESC; which gives me a list of the number of selections in descending order which is just what I'm looking for. Thanks again for your help |
|
#4
|
|||
|
|||
|
RE: finding duplicates
How would one find duplicates in a mysql database in the field "email" then export a comma delimited de-duped list ?
|
|
#5
|
||||
|
||||
|
RE: RE: finding duplicates
Quote:
You can just select all distinct email addresses, then there is no de-duping: SELECT DISTINCT email FROM table_name |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > finding duplicates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|