Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 28th, 2014  |  syntax: PL/SQL  |  size: 0.71 KB  |  views: 82  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --Given something like this:
  2. SELECT a, b, c, d, e, f, g, MOD(a,c) md, SUBSTR(c,1,8) FROM mytable WHERE a = b AND b = c AND e NOT IN (f,g) AND (d IS NULL OR e IS NOT NULL);
  3.  
  4. --I want to get this:
  5.  SELECT a,
  6.         b,
  7.         c,
  8.         d,
  9.         e,
  10.         f,
  11.         g,
  12.         MOD(a, c) md,
  13.         SUBSTR(c, 1, 8)
  14.    FROM mytable
  15.   WHERE a = b
  16.     AND b = c
  17.     AND e NOT IN(f, g)
  18.     AND (d IS NULL
  19.          OR e IS NOT NULL);
  20.          
  21. --The closest I could get is:
  22.  SELECT a,
  23.   b,
  24.   c,
  25.   d,
  26.   e,
  27.   f,
  28.   g,
  29.   MOD(a, c) md,
  30.   SUBSTR(c, 1, 8)
  31.    FROM mytable
  32.   WHERE a = b
  33.   AND b = c
  34.   AND e NOT IN(f, g)
  35.   AND(d IS NULL
  36.   OR e IS NOT NULL) ;
  37.  
  38. --...Which looks "somewhat" different.
clone this paste RAW Paste Data