php - Doubts about creating an specific query -


ok have database generate ticket code everytime users buy item. code have oportunity win price

to win price have go register form, code ask.. thats data generated. ask name, mail address, , other non important stuff

this part working nice , properly. need create o new function detect best buyers. when enter code participate , ask mail, have noticed, enters same mail each time register code. best way think select best clients, , interested on promotions also.

so think best build query search mail row .. inside users table, , coincidences, , query can drop me list of "repited" mails in dsc order,

is posible, can build query this? how?

ok , thansk comments (why downvote??) anyway

the structure is

id | name | lastname | mail | phone | zipcode | birth |

and sorry @ moment cant figure out query thats why ask. sorry been fool ,

how order number of times element occurs in table

select count(*) top,mail,name lastname users group mail order top desc

this works because of aggregate functions

count

picks number of rows in individual elements of group (so suppose ran count without group return number of rows in table)

group by

groups rows common elements column(s) specified group by.

so in above case group mails , count rows in each group.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -