How to create Query for postgreSQL 'advanced' query

Guilherme Nogueira
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 22, 2015

Hi guys,

 

I have this Select:

SELECT "field_1", "field_2","field_3", MIN(COALESCE(NULLIF("field_4",'') ,'TBD')) MINDP,MIN("field_5") MINBOD FROM "MY_TABLE" GROUP BY "field_1", "field_2","field_3"

 

And when I try to use:

 

import net.java.ao.Query;

    public List<myClass> find() {

        String SQL = "SELECT \"field_1\", \"field_2\",\"field_3\", MIN(COALESCE(NULLIF(\"field_4\",'') ,'TBD')) MINDP,MIN(\"field_5\") MINBOD FROM \"MY_TABLE\" GROUP BY \"field_1\", \"field_2\",\"field_3\""

        return newArrayList(ao.find(myClass.class, Query.select(SQL)));

    }

 

My code bring all issues in table (does not execute select).

 

But when I run this query in postgreSQL console, It works sad

 

Any suggestions?

Thanks smile

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Guilherme Nogueira
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2015

Actually I changed my code to: return newArrayList(ao.findWithSQL(myClass.class, "ANY_INT_column_inRESULT",SQL)); and it worked :) but I still want to know why this is not working

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 23, 2015

Again, this is a SQL question, not an Atlassian one. I'd ask it in a postgresql forum

Guilherme Nogueira
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2015

ok yeah you are right! just commenting for somebody with same problem. Thank you.

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 22, 2015

I'd suggest asking in a Java/SQL forum - it might be running in JIRA, but you're not asking about JIRA really, it's a SQL and Java question that has nothing to do with JIRA (in fact, any recommendation about JIRA and SQL is "don't use SQL against a JIRA database, do it properly and use the API.  And JIRA is broadly database agnostic too)

TAGS
AUG Leaders

Atlassian Community Events