I am having a rather odd problem. I have native query which runs perfectly when executed on sql server:

```
SELECT  date_time, GREATEST(sum(count_up - count_down) OVER (PARTITION BY date_trunc('day', result.date_time) ORDER BY date_time),0) AS cum_amt FROM   peoplecounting.result order  BY date_time;

```

However, using this query as native query in JPA results in syntax error

```
@NamedNativeQueries({@NamedNativeQuery(
        name = "Result.getTotal",
        query = "SELECT  date_time, GREATEST(sum(count_up - count_down) OVER (PARTITION BY date_trunc('day', peoplecounting.result.date_time) ORDER BY date_time),0) AS cum_amt FROM   peoplecounting.result order  BY date_time;")})

public class Result implements Serializable {...

```

///

```
@Entity
@SqlResultSetMapping(name = "TotalResultMapping", entities = {@EntityResult(entityClass = TotalResult.class, fields = {@FieldResult(name = "total", column = "cum_amt"), @FieldResult(name = "date", column = "date_time")})})

public class TotalResult {

private static final long serialVersionUID = 1L;

public TotalResult() {
}

@Id Date date;

public Date getDate() {
    return date;
}

public void setDate(Date date) {
    this.date = date;
}

public Integer getTotal() {
    return total;
}

public void setTotal(Integer total) {
    this.total = total;
}

Integer total;

```

}

When calling: `em.createNativeQuery("Result.getTotal","TotalResultMapping").getResultList();`

I get:

```
INFO  [stdout] (default task-44) Hibernate: Result.getTotal
WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-44) SQL Error: 0, SQLState: 42601
ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-44) Error: Syntax error at or near "Result"

```