Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
5warriors
Starting Member
2 Posts |
Posted - 2015-03-05 : 19:42:29
|
I have two tables.Example:Table1 – Information about usersID LastName FirstName Department JobDesc———————————————————————1 Doe John SQL Team SQL Trainee2 Doe Jane SQL Team SQL Trainee3 Vader Darth SQL Dark SQL MasterTable2 – Submitted InformationID DateSubmitted Department Table1_ID FirstName LastName GradeLevel Grade—————————————————————————————————————————22 2015-03-04 00:00:00 SQL Team 2 Jane Doe Low 1823 2015-03-05 00:00:00 SQL Team 1 John Doe High 22On table1 are the records of all users.On table2 are the records of the users who submitted some information per day.I need to get a report that have the users that have not submitted (NULL) and the users that have submitted per day. In the same report.I already have something going, but a user who submits on "2015-03-04” and has not submitted on the "2015-03-05" is not seen on the report on the "2015-03-05” as not submitted (NULL) for column “DateSubmitted, GradeLevel, Grade”.SELECT Table1.FirstName ,Table1.LastName ,Table1.Deptartment ,Table1.JobDesc ,Table2.DateSubmitted ,Table2.GradeLevel ,Table2.GradeFROM Table1 FULL JOIN Table2 ON Table1.ID = Table2.Table1_IDWHERE (Table2.DateSubmitted = '2015-03-05 00:00:00' or Table2.DateSubmitted is Null)Need report(query) to look something like this for the Date Submitted of 2015-03-05ID LastName FirstName Department JobDesc Date_Submitted GradeLevel Grade—————————————————————————————————————————John Doe SQL Team SQL Trainee 2015-03-05 00:00:00 High 22Jane Doe SQL Team SQL Trainee NULL NULL NULLDarth Vader SQL Dark SQL Master NULL NULL NULLNeed report(query) to look something like this for the Date Submitted of 2015-03-04ID LastName FirstName Department JobDesc Date_Submitted GradeLevel Grade—————————————————————————————————————————John Doe SQL Team SQL Trainee NULL NULL NULLJane Doe SQL Team SQL Trainee 2015-03-04 00:00:00 Low 18Darth Vader SQL Dark SQL Master NULL NULL NULLHopefully someone can help.Thanks in advance. |
|
jleitao
Posting Yak Master
100 Posts |
Posted - 2015-03-06 : 13:49:14
|
Try this:SELECTTable1.FirstName,Table1.LastName,Table1.Deptartment,Table1.JobDesc,Table2.DateSubmitted,Table2.GradeLevel,Table2.GradeFROM Table1LEFT JOIN Table2 ON Table1.ID = Table2.Table1_IDAND Table2.DateSubmitted = '2015-03-05 00:00:00'------------------------PS - Sorry my bad english |
|
|
5warriors
Starting Member
2 Posts |
Posted - 2015-03-06 : 17:23:09
|
Worked Great! Thanks for your help jleitao!!! |
|
|
|
|
|
|
|