Results 1 to 5 of 5

Thread: Super Beginner Question

  1. #1
    Join Date
    Apr 2003
    Posts
    2

    Question Super Beginner Question

    Begging your patience, I'm wondering if someone can help me with a beginner question. I am trying to write a query against our trouble ticket DB. I want to find tickets that have multiple tech assignments associated with a single ticket. How can write a query that says if in the CALLID field you find the same value more than once, return those rows and only those rows?

    Thanks very much.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Do you have sample table schema and data?

  3. #3
    Join Date
    Apr 2003
    Posts
    2
    Is the attached adequate? Thanks so much!
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2003
    Location
    Jacksonville, Florida
    Posts
    52
    Couldn't you just:

    Code:
    SELECT *.p, CallCount.s
    FROM TicketTable p
      RIGHT OUTER JOIN (
        SELECT CallId, Count(CallId) AS CallCount 
        FROM TicketTable
        GROUP BY CallId
        WHERE CallCount > 1
      ) s
    Last edited by rwendel; 04-09-2003 at 03:47 PM.

  5. #5
    Join Date
    Mar 2003
    Location
    Jacksonville, Florida
    Posts
    52
    Sorry, the code had to be corrected...
    I was in a rush

    Code:
    SELECT p.*, s.CallCount
    FROM TicketTable p
      RIGHT OUTER JOIN (
        SELECT CallId, Count(CallId) AS CallCount 
        FROM TicketTable
        GROUP BY CallId
        WHERE CallCount > 1
      ) s ON p.CallId = s.CallId

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •