home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / database / oracle / 1578 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  2.5 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!rpi!bu.edu!dartvax!kip-sn-49.dartmouth.edu!user
  2. From: carl.pedersen@dartmouth.edu (L. Carl Pedersen)
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: Weird GROUP BY/TO_CHAR(date) Interaction?
  5. Message-ID: <carl.pedersen-140992111744@kip-sn-49.dartmouth.edu>
  6. Date: 14 Sep 92 15:30:52 GMT
  7. References: <carl.pedersen-110992122420@kip-sn-49.dartmouth.edu>
  8. Sender: news@dartvax.dartmouth.edu (The News Manager)
  9. Followup-To: comp.databases.oracle
  10. Organization: Dartmouth College
  11. Lines: 84
  12.  
  13. I have further isolated the problem described in my previous posting on
  14. this subject.  It appears to require a view, hence I suspect a kernel
  15. problem.  I feel hesitant to call it a bug, since I'm not sure what it
  16. should be doing.  There is no need to refer to my previous message.  Here's
  17. what you need to reproduce the problem:
  18.  
  19. $ sqlplus /
  20.  
  21. SQL*Plus: Version 3.0.11.5.1 - Production on Mon Sep 14 10:09:11 1992
  22.  
  23. Copyright (c) Oracle Corporation 1979, 1992.  All rights reserved.
  24.  
  25.  
  26. Connected to:
  27. ORACLE RDBMS V6.0.35.1.0 (6.2), transaction processing option - Production
  28. PL/SQL V1.0.34.2.0 - Production
  29.  
  30. SQL> create table bug1(d char(4));
  31. Table created.
  32. SQL> insert into bug1 values('9203');
  33. 1 row created.
  34. SQL> insert into bug1 values('9204');
  35. 1 row created.
  36. SQL> insert into bug1 values('9205');
  37. 1 row created.
  38. SQL> insert into bug1 values('9205');
  39. 1 row created.
  40. SQL> create view bug1v as select to_date(d,'YYMM') d from bug1;
  41. View created.
  42.  
  43. SQL> select d from bug1v;
  44. D
  45. ---------
  46. 01-MAR-92
  47. 01-APR-92
  48. 01-MAY-92
  49. 01-MAY-92
  50.  
  51. 4 rows selected.
  52.  
  53. SQL> select to_char(d) from bug1v;
  54. TO_CHAR(D)
  55. ---------------------------------------------------------------------------
  56. 01-MAR-92
  57. 01-APR-92
  58. 01-MAY-92
  59. 01-MAY-92
  60.  
  61. 4 rows selected.
  62.  
  63. SQL> select d from bug1v group by d;
  64. D
  65. ---------
  66. 01-MAR-92
  67. 01-APR-92
  68. 01-MAY-92
  69.  
  70. 3 rows selected.
  71.  
  72. SQL> select to_char(d) from bug1v group by to_char(d);
  73.  
  74. TO_CHAR(D)
  75. ---------------------------------------------------------------------------
  76. 01-APR-92
  77. 01-MAR-92
  78. 01-MAY-92
  79.  
  80. 3 rows selected.
  81.  
  82. SQL> select to_char(d) from bug1v group by d;
  83. TO_CHAR(D)
  84. ---------------------------------------------------------------------------
  85. 01-MAY-92
  86. 01-MAY-92
  87. 01-MAY-92
  88.  
  89. 3 rows selected.
  90.  
  91. SQL>
  92.  
  93. The results of the last select are baffling to me.  I realize there is no
  94. reasons to leave out the to_char in the group by, but why does it matter? 
  95. It does what I expect if I replace bug1v with a table containing the date
  96. values.  We're on VMS 5.3.
  97.