Simple SQL Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trueadvantage
    New Member
    • Feb 2008
    • 12

    Simple SQL Problem

    I have 1 confusion about query.

    I have one data sheet which has students name and their marks.

    some of the student has got same marks. I want to find out their names.

    e.g.: - A 50
    B 40
    C 50
    D 40
    E 60
    F 60

    I want to make query for this. which will help me to find out the duplicates from that sheet means if i put "50" in a particular field the result should display as "A" "C" (bcoz "A" , "C" has got same marks.)

    Please let me know if you have any suggestion or solution

    Thanks,
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32663

    #2
    Please be careful where you post your questions. I found this appended to an unrelated HowTo article (Accessing Field Values in Recordsets).

    Admin.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32663

      #3
      In response to your question, you would use SQL similar to the following (you provide little information so I had to make up my own table and field names):
      Code:
      SELECT [StudentName], [Mark]
      FROM [tblStudent]
      WHERE [Mark] In(SELECT [Mark]
                      FROM [tblStudent]
                      GROUP BY [Mark]
                      HAVING Count(*)>1)

      Comment

      • trueadvantage
        New Member
        • Feb 2008
        • 12

        #4
        Originally posted by NeoPa
        In response to your question, you would use SQL similar to the following (you provide little information so I had to make up my own table and field names):
        Code:
        SELECT [StudentName], [Mark]
        FROM [tblStudent]
        WHERE [Mark] In(SELECT [Mark]
                        FROM [tblStudent]
                        GROUP BY [Mark]
                        HAVING Count(*)>1)
        Hi...

        First I Apologize for putting question in Howtos. and Thanks a lot for help. I will try with this query. If again i meet with same problem I will let you know all details about the work which im doin.

        Thanks a lot

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32663

          #5
          Not to worry too much.
          It's early days and we all make mistakes at the start.

          Welcome to TheScripts :)

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32663

            #6
            Ah, I just reminded myself of the whole story with the double-post and all.
            Again - no worries. I guess the first post got lost to you as it was posted in the HowTo by mistake.

            Click on Subscribed (in blue at top) to find any threads you've been involved in.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32663

              #7
              This thread now continues in another one (Query Problem).

              Comment

              Working...