Forum Replies Created

Viewing 5 posts - 106 through 110 (of 110 total)

  • RE: COUNT DISTINCT ISSUE

    SELECT A.PostCode, A.[Count],

           A.Suburb, B.Latitude, B.Longitude

      FROM (SELECT Z.Postcode, Suburb = MIN(Z.Suburb),

                   [Count] = (SELECT COUNT(*) FROM #tblMembers Y WHERE Y.Postcode = Z.Postcode)

              FROM #tblPostcodes Z GROUP BY Z.PostCode) A

       ...

  • RE: COUNT DISTINCT ISSUE

    SELECT A.PostCode, [Count] = (SELECT COUNT(*) FROM tblMembers Z WHERE Z.Postcode = A.Postcode),

           A.Suburb, B.Latitude, B.Longitude

      FROM (SELECT Z.Postcode, Suburb = MIN(Z.Suburb) FROM tblPostcodes Z GROUP BY Z.PostCode) A

        INNER...

  • RE: Error in Query

    Hi,

    [DateEntered] BETWEEN (( YEAR([DateEntered]) = 2006 AND MONTH([DateEntered]) =12 AND DAY([DateEntered]) = 12)

         AND ( YEAR([DateEntered]) = 2007 AND MONTH([DateEntered]) = 12 AND DAY([DateEntered]) = 12))

    should say

    [DateEntered] BETWEEN '20061212' AND...

  • RE: Insert numeric ID with interval

    Try

     

    SELECT A.AreaCode, A.AreaName,

    A.AreaCode * 100 + (SELECT COUNT(*) FROM tablename Z WHERE Z.AreaCode = A.AreaCode AND Z.AreaName <= A.AreaName)

    FROM tablename A

    ORDER BY A.AreaCode, A.AreaName

    K. Matsumura

  • RE: Selecting one row for each value in another column

    Hello,

    If you prefre not to use an intermediate table, try this:

    SELECT c.course_id, c.course_title, i.instructor_id, i.instructor_name

    FROM courses c

    INNER JOIN roster r on c.course_id = r.course_id

    and r.instructor_id = (SELECT MAX(Z.instructor_id) FROM...

Viewing 5 posts - 106 through 110 (of 110 total)