2

Say I want to select rows with a date range or date_feild > 2009-06-01 && date_field < 2009-07-01. and I want to select the first_name_field and last_name_field but I only want the same name (F+L) to show up once per date. So the same name can show up, multiple times as long as their dates are different; but not if the names are on the same date. Does that makes sense? we are trying to track how many inquiries we got over a time period, but if the same user made multiple inquiries on the same day we want to count that as just 1.

I haven't even starting to program this yet so I am open to all suggestions.

Thanks!

JD Isaacks
  • 56,088
  • 93
  • 276
  • 422

3 Answers3

3

use GROUP BY

SELECT date,name FROM table GROUP BY date,name
duckyflip
  • 16,189
  • 5
  • 33
  • 36
0

Don't know in mySQL but in SQL Server you can use COUNT DISTINCT.

SELECT
    date_field,
    COUNT(DISTINCT first_name + last_name)
FROM
    YourTable
GROUP BY
    date_field
Robin Day
  • 100,552
  • 23
  • 116
  • 167
0

The answer is inside your question:

select distinct date, concat(first_name, ' ', last_name) from table
Bogdan Gusiev
  • 8,027
  • 16
  • 61
  • 81