title: JSqlParser：CCJSqlParserUtil.parse(sql) Exception;
body: <p>In the sqlserver 2008:</p>
  
  <pre><code>/**
   sql1：use Subquery AS 'PIVOT' ResultSet
  */
  SELECT * FROM (
      SELECT a.Station_ID stationId, b.Factor_Code factoryCode, a.Value value 
      FROM T_Data_Real a 
      LEFT JOIN T_Bas_Factor b ON a.Factor_ID = b.Id
  )f
  PIVOT (max(f.value) for f.factoryCode in (ZD, COD, SW, PH))d
  
  /**
   sql2：use with
  */
  WITH A AS(
      SELECT a.Station_ID stationId, b.Factor_Code factoryCode, a.Value value 
      FROM T_Data_Real a 
      LEFT JOIN T_Bas_Factor b ON a.Factor_ID = b.Id)
  SELECT * FROM A
  PIVOT (max(value) for factoryCode in (ZD, COD, SW, PH))d
  </code></pre>
  
  <p>Executing the above two statements in SSMS has the same result.</p>
  
  <p>but When I use the method  to format sql 1 and 2：</p>
  
  <pre><code>CCJSqlParserUtil.parse(sql) 
  </code></pre>
  
  <p><strong>The first one throws an exception，I can't use Subquery AS 'PIVOT' ResultSet.</strong></p>
  
  <p>The Exception Message like this:</p>
  
  <pre><code>net.sf.jsqlparser.JSQLParserException
      at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:56)
      at spring.commons.api.test.sqltest.test1(sqltest.java:27)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
      at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
      at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
      at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      at java.util.Iterator.forEachRemaining(Iterator.java:116)
      at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
      at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
      at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
      at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
      at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:83)
      at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:74)
      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:137)
      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:87)
      at org.junit.platform.launcher.Launcher.execute(Launcher.java:93)
      at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:61)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
  Caused by: net.sf.jsqlparser.parser.ParseException: Encountered " "PIVOT" "pivot "" at line 1, column 184.
  Was expecting one of:
      &lt;EOF&gt; 
      "JOIN" ...
      "LEFT" ...
      "CROSS" ...
      "FULL" ...
      "WHERE" ...
      "FOR" ...
      "UNION" ...
      "GROUP" ...
      "INNER" ...
      "ORDER" ...
      "RIGHT" ...
      "HAVING" ...
      "NATURAL" ...
      "INTERSECT" ...
      "EXCEPT" ...
      "MINUS" ...
      "START" ...
      "CONNECT" ...
      ";" ...
      "," ...
      "ORDER" ...
      "ORDER" ...
  
      at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:16869)
      at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:16722)
      at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:91)
      at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:54)
      ... 40 more
  </code></pre>
  
  <p>please help me!</p>