home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / bit / listserv / sasl / 4039 < prev    next >
Encoding:
Text File  |  1992-09-03  |  7.0 KB  |  175 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!uvaarpa!darwin.sura.net!paladin.american.edu!auvm!LEICESTER.AC.UK!MAIL_SYSTEM
  3. Via: uk.ac.leicester; Thu, 3 Sep 1992 16:18:32 +0100
  4. Message-ID: <SAS-L%92090311202704@VTVM2.BITNET>
  5. Newsgroups: bit.listserv.sas-l
  6. Date:         Thu, 3 Sep 1992 16:18:00 BST
  7. Reply-To:     Mail_System@LEICESTER.AC.UK
  8. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  9. From:         Mail_System@LEICESTER.AC.UK
  10. Subject:      %% Undelivered Mail %%
  11. Comments: To: SAS-L <SAS-L@VTVM2.CC.VT.EDU>
  12. Lines: 161
  13.  
  14. Your mail was not delivered as follows:
  15. %MAIL-E-USERSPEC, invalid user specification '@UK.AC.LEICESTER.IRIX'
  16.  
  17. Your original mail header and message follow.
  18.  
  19. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  20. Via: UK.AC.NSFNET-RELAY; Thu, 3 Sep 92  16:18 BST
  21. Received: from vtvm2.cc.vt.edu by sun3.nsfnet-relay.ac.uk with Internet SMTP
  22.           id <sg.25629-0@sun3.nsfnet-relay.ac.uk>;
  23.           Thu, 3 Sep 1992 16:10:06 +0100
  24. Received: from vtvm2.cc.vt.edu by VTVM2.CC.VT.EDU (IBM VM SMTP V2R2) with BSMTP
  25.           id 9553; Thu, 03 Sep 92 11:08:47 EDT
  26. Received: from VTVM2.BITNET by vtvm2.cc.vt.edu (Mailer R2.08 R208002)
  27.           with BSMTP id 1536; Thu, 03 Sep 92 11:07:56 EDT
  28. Date: Thu, 3 Sep 1992 16:05:00 BST
  29. Reply-To: Mail_System@UK.AC.LEICESTER
  30. Original-Sender: "SAS(r) Discussion" <SAS-L@EDU.VT.CC.VTVM2>
  31. From: Mail_System@UK.AC.LEICESTER
  32. Subject: %% Undelivered Mail %%
  33. Comments: To: SAS-L <SAS-L@VTVM2.CC.VT.EDU>
  34. To: Multiple recipients of list SAS-L <SAS-L@EDU.VT.CC.VTVM2>
  35. Sender: SAS-L@EDU.VT.CC.VTVM2
  36.  
  37. Your mail was not delivered as follows:
  38. %MAIL-E-USERSPEC, invalid user specification '@UK.AC.LEICESTER.IRIX'
  39.  
  40. Your original mail header and message follow.
  41.  
  42. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  43. Via: UK.AC.NSFNET-RELAY; Thu, 3 Sep 92  16:05 BST
  44. Received: from vtvm2.cc.vt.edu by sun3.nsfnet-relay.ac.uk with Internet SMTP
  45.           id <sg.25320-0@sun3.nsfnet-relay.ac.uk>;
  46.           Thu, 3 Sep 1992 16:05:12 +0100
  47. Received: from vtvm2.cc.vt.edu by VTVM2.CC.VT.EDU (IBM VM SMTP V2R2) with BSMTP
  48.           id 9502; Thu, 03 Sep 92 11:04:15 EDT
  49. Received: from VTVM2.BITNET by vtvm2.cc.vt.edu (Mailer R2.08 R208002)
  50.           with BSMTP id 1170; Thu, 03 Sep 92 11:03:37 EDT
  51. Date: Thu, 3 Sep 1992 15:58:00 BST
  52. Reply-To: Mail_System@UK.AC.LEICESTER
  53. Original-Sender: "SAS(r) Discussion" <SAS-L@EDU.VT.CC.VTVM2>
  54. From: Mail_System@UK.AC.LEICESTER
  55. Subject: %% Undelivered Mail %%
  56. Comments: To: SAS-L <SAS-L@VTVM2.CC.VT.EDU>
  57. To: Multiple recipients of list SAS-L <SAS-L@EDU.VT.CC.VTVM2>
  58. Sender: SAS-L@EDU.VT.CC.VTVM2
  59.  
  60. Your mail was not delivered as follows:
  61. %MAIL-E-USERSPEC, invalid user specification '@UK.AC.LEICESTER.IRIX'
  62.  
  63. Your original mail header and message follow.
  64.  
  65. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  66. Via: UK.AC.NSFNET-RELAY; Thu, 3 Sep 92  15:57 BST
  67. Received: from vtvm2.cc.vt.edu by sun3.nsfnet-relay.ac.uk with Internet SMTP
  68.           id <sg.24811-0@sun3.nsfnet-relay.ac.uk>;
  69.           Thu, 3 Sep 1992 15:57:11 +0100
  70. Received: from vtvm2.cc.vt.edu by VTVM2.CC.VT.EDU (IBM VM SMTP V2R2) with BSMTP
  71.           id 9451; Thu, 03 Sep 92 10:56:11 EDT
  72. Received: from VTVM2.BITNET by vtvm2.cc.vt.edu (Mailer R2.08 R208002)
  73.           with BSMTP id 0631; Thu, 03 Sep 92 10:56:09 EDT
  74. Date: Thu, 3 Sep 1992 10:48:34 EDT
  75. Reply-To: Andy Norton <76350.1604@COM.COMPUSERVE>
  76. Original-Sender: "SAS(r) Discussion" <SAS-L@EDU.VT.CC.VTVM2>
  77. From: Andy Norton <76350.1604@COM.COMPUSERVE>
  78. Subject: Re: Finding non-dups via SQL (multiple keys)
  79. Comments: To: SAS-L <SAS-L@AWIIMC12.IMC.UNIVIE.AC.AT>
  80. To: Multiple recipients of list SAS-L <SAS-L@EDU.VT.CC.VTVM2>
  81. Sender: SAS-L@EDU.VT.CC.VTVM2
  82.  
  83. ----------------------------------------------------------------------
  84. CONTENT:    Information
  85. SUMMARY:   Jim Clark's response to Ray Pass is correct for single
  86.            keys.  Here are solutions for multiple keys.
  87. REL/PLTF:  6.07.01/CMS, 6.04/PC-DOS
  88. E-ADDR:    76350.1604@compuserve.com
  89. NAME:      Andy Norton
  90. ADDRESS:   Trilogy Consulting, 5228 Lovers Lane, Kalamazoo MI 49002
  91. PHONE:     (616) 344-2191
  92. ----------------------------------------------------------------------
  93.  
  94. Ray Pass had asked for a method to identify CASENO's in FILE1 that do
  95. not occur in FILE2.
  96.  
  97. Jim Clark responded with
  98. > title 'Eval Courses NOT IN Class Courses';
  99. > select distinct e.ident, e.ins
  100. >    from work.check e, f.course c
  101. >    where e.ident not in
  102. >     (select c.ident
  103. >      from f.course c)
  104. >    order by e.ident;
  105.  
  106. The general approach is correct and sufficient for Ray's problem.  I
  107. think you could use simply
  108.   select    CHECK.*
  109.   from      WORK.CHECK
  110.   where     CHECK.IDENT not in
  111.             ( select IDENT
  112.               from   F.COURSE)
  113.   order by  IDENT;
  114. to get the same result.  In other words, it is not necessary to join E
  115. with C in order to reference table C in a subquery.
  116.  
  117. The main purpose of my posting, however, is to point out that this
  118. method falls apart when you need to match on two keys instead of one.
  119. Suppose the IDENT's are repeated within different colleges, and you
  120. need to do a combined analysis.  Now the observations are identified
  121. with {COLLEGE, IDENT}.  The IN operator only works for a single
  122. variable, so can't handle this situation.
  123.  
  124. This is a widespread weakness in the design of SQL:  programs that work
  125. with single columns often cannot be extended to handle multiple
  126. columns.  If you write the program to handle multiple keys, it will be
  127. able to handle the single-key situation.
  128.  
  129. For a general solution which works with multiple keys, use
  130.   select    *
  131.   from      WORK.CHECK
  132.   where     not exists
  133.             ( select *
  134.               from   F.COURSE
  135.               where  COLLEGE = CHECK.COLLEGE and
  136.                      IDENT   = CHECK.IDENT)
  137.   order by  COLLEGE, IDENT;
  138.  
  139.   This is fairly intelligible but can be inefficient with the current
  140. optimizer, because the subquery is independently evaluated for each set
  141. of {COLLEGE, IDENT} values.  Defining indexes on COLLEGE and IDENT (in
  142. the COURSE file) could help.
  143.  
  144. It may be possible for the optimizer to automatically convert
  145. subqueries to joins in the future.
  146.  
  147. This alternative may be more efficient (depending on factors such as
  148. how many distinct {COLLEGE, IDENT} sets there are).  I haven't tested
  149. enough to determine exactly what the trade-offs are:
  150.  
  151.   select    CHECK.*
  152.   from      WORK.CHECK,
  153.             ( select COLLEGE, IDENT
  154.               from   WORK.CHECK
  155.               except
  156.               select COLLEGE, IDENT
  157.               from   F.COURSE) as NONDUP
  158.   where     CHECK.COLLEGE = NONDUP.COLLEGE and
  159.             CHECK.IDENT   = NONDUP.IDENT
  160.   order by  COLLEGE, IDENT;
  161.  
  162. Unlike the earlier subquery solution, this program processes all of the
  163. different {COLLEGE, IDENT} pairs together.
  164.  
  165.                     Andy
  166.  
  167. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  168. End of returned mail
  169.  
  170. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  171. End of returned mail
  172.  
  173. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  174. End of returned mail
  175.