Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 13th, 2012  |  syntax: None  |  size: 0.48 KB  |  hits: 36  |  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. SQL query that works in postgre 9.1 :
  2.  
  3. SELECT sum(count), date_part('WEEK', tcreated) as week
  4. FROM usulTests
  5. GROUP BY week
  6. ORDER BY week DESC
  7.  
  8. And the JPA (eclipselink 2.3.2) version that doesn't work :
  9.  
  10. SELECT SUM(b.count), FUNC('date_part','WEEK', b.tcreated) AS week FROM BidLEntreprise b GROUP BY week ORDER BY week
  11.  
  12. The exception :
  13. org.postgresql.util.PSQLException: ERROR: column "usulTests.tcreated" must appear in the GROUP BY clause or be used in an aggregate function