sql - Min(date) returning conflicting Results - Tableau -
long time observer, first time poster:
i'm using sql capabilities in tableau. query return userid (sqlcec), date of attendance (sql date), , first time user has ever attended (firstattendancedate).
select [attendees$].[cec] [sqlcec] , [attendees$].[date] [sql date] , [data2].[firstattendancedate] [attendees$] inner join(select [attendees$].[name] , min([attendees$].[date])as [firstattendancedate] [attendees$] group [attendees$].[name])as [data2] on [attendees$].[name] = [data2].[name] [attendees$].[cec] in ("jakyles","ajannett") order [attendees$].[cec],[attendees$].[date] the code returns following results:
sqlcec sql date firstattendancedate ajannett 12/9/2014 0:00 12/9/2014 0:00 ajannett 4/14/2015 0:00 12/9/2014 0:00 ajannett 6/23/2015 0:00 12/9/2014 0:00 jakyles 12/9/2014 0:00 12/9/2014 0:00 jakyles 5/12/2015 0:00 12/9/2014 0:00 jakyles 6/23/2015 0:00 6/23/2015 0:00 i trying figure out why firstattendancedate column returning "6/23/2015" user jackyles (which not want) while user ajannett returning desired results. new user sql. missing fundamentally? thank help!
my guess, without seeing original tables, has contents of name column opposed cec column. suspect if add name column result set, contents of column last 2 lines different name column though same sqlcec column.
my suggestion change references in query name cec:
select [attendees$].[cec] [sqlcec] , [attendees$].[date] [sql date] , [data2].[firstattendancedate] [attendees$] inner join(select [attendees$].[cec] , min([attendees$].[date])as [firstattendancedate] [attendees$] group [attendees$].[cec])as [data2] on [attendees$].[cec] = [data2].[cec] [attendees$].[cec] in ("jakyles","ajannett") order [attendees$].[cec],[attendees$].[date]
Comments
Post a Comment