Results 1 to 4 of 4
  1. #1
    SarahBeth is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    2

    How to display the same field in a query with different data

    I am trying to mock up a simple version of a solution to a problem and I can’t think of the life of me how to solve it
    I have the following table

    Click image for larger version. 

Name:	tab.png 
Views:	13 
Size:	228.9 KB 
ID:	16207

    Each student is on two courses. I want to create a query that will display the students name and email from the student table (linked by ID to StuID) along with their non Knitting CourseName, Start and end date for that and then the knitting courseName and the end date for that.

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    I can only see Courses table. I can try to come up with some base on your description.

    SELECT STUDENT.STUDENTSNAME, STUDENT.STUDENTEMAIL, COURSES.COURSENAME, COURSES.COURSESTART, COURSES.COURSEEND
    FROM STUDENT INNER JOIN COURSES ON STUDENT.ID = COURSES.STUID
    WHERE (((COURSES.COURSENAME)<>"Knitting"));

  3. #3
    SarahBeth is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    2
    Thanks but that's not quite what I mean. Maybe I haven't explained clearly enough.

    What I would like to display would be the following

    StudentName | StudentEmail | CourseTitle (whatever non knitting course they are on) | Course Start date (for that course) | Course End date (for that course) | Course End date for the knitting course.

    (the info I have given here is just a mock up but to give some context what I am trying to display is the PhD course a student is on as well as info about when their Transferrable Skills course is also finishing.
    Hope that makes sense

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why do you need them side-by-side? Could just build a report that orders and groups records by StuID.

    Otherwise, try:

    SELECT StudentName, Email,
    Max(IIf(CourseName<>"Knitting", CourseName, Null)) AS PHDCourse,
    Max(IIf(CourseName<>"Knitting", CourseStart, Null)) AS PHDStart,
    Max(IIf(CourseName<>"Knitting", CourseEnd, Null)) AS PHDEnd,
    Max(IIf(CourseName="Knitting", CourseEnd, Null)) AS KnittingEnd
    FROM Student INNER JOIN Courses ON Student.ID = Courses.StuID GROUP BY StudentName, Email;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Dont want to display 0.00 data on a query
    By keiath in forum Queries
    Replies: 7
    Last Post: 03-09-2014, 07:52 AM
  2. Replies: 3
    Last Post: 12-13-2013, 10:28 AM
  3. Display Query field in form?
    By Ray67 in forum Queries
    Replies: 17
    Last Post: 06-01-2012, 12:44 PM
  4. Select a field in a row and display data
    By Darkladymelz in forum Reports
    Replies: 15
    Last Post: 03-13-2012, 03:39 PM
  5. Replies: 1
    Last Post: 03-02-2006, 06:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums