Postgres mistaking value as a colum [duplicate] - postgresql

This question already has answers here:
What is the difference between single quotes and double quotes in PostgreSQL?
(3 answers)
Simple Postgresql Statement - column name does not exists
(2 answers)
Closed 12 months ago.
The community reviewed whether to reopen this question 12 months ago and left it closed:
Original close reason(s) were not resolved
I have a section of a larger query, which we are working on converting from SQL to postgres that is giving an error of (Error: column "CEL" does not exist) and I am not sure why as CEL is a value nota column. I get the same result if I change "CEL" to CEL.
Select id, MIN(pos) as position from perphone
where personal_phone_type = "CEL"
GROUP BY id

"" is for quoting identifiers like columns and tables.
'' is for quoting constant values
select
id,
min(pos) as position
from perphone
where personal_phone_type = 'CEL'
group by id

Related

Is there any PostgreSQL magic to get results by range instead of rows? [duplicate]

This question already has answers here:
Find gaps of a sequence in PostgreSQL tables
(1 answer)
Group rows by an incrementing column in PostgreSQL
(1 answer)
Group sequential integers postgres
(3 answers)
Closed 10 months ago.
I'm sorry for the title, I don't know how to clearly summarize the problem.
That's probably why I couldn't find an answer when searching by myself.
Feel free to improve it.
Anyways, let's say I have a query returning primary id's.
SELECT id FROM ...
Instead of having results presented with one row for each id like this:
id
-----
1
2
3
45
182
183
184
I would like to know if there's any access to some internal state based on the index that would return this:
ranges
---------
1-3
45
182-184
The whole point here is NOT to have a nice presentation, I can do that.
Besides it would add a treatment after having run the query, I want the opposite.
I'd like to know if it exists some king of shortcut that would accelerate the query by not having to return each row individually.
Maybe something related to extracting data directly from the indexes used in the WHERE clause.
I'm not aware of a generic SQL way to do that but I would love to know if there's some postgres feature for this.
If the answer is "no", it's ok. I just had to ask...

How to sum the data of a column in Jasper Report [duplicate]

This question already has answers here:
How can I increment a variable with value of another variable in JasperReports?
(3 answers)
How to sum all values in a column in Jaspersoft iReport Designer?
(2 answers)
Closed 2 years ago.
I want to make a Jasper Report that desplays a field and at the end it sums all the numbers from it. The problem is that the column is java.lang.String because it has dashes(-) and numbers.
For example I have the column in the picture. I create a variable that sums every number of the column. For every dash it should add a zero. So for the example column the result should be sum=282.
I tried the following.
IF(Boolean.valueOf($F{Column}).equals("-") ? $V{Sum} = $V{Sum } + 0 : $V{Sum}= $V{Sum} + Long.parseLong($F{Column}))
But it gives an error "The left-hand side of an assignement must be a variable"
Does anyone have any ideas on how to do it correctly? Thank you!

Jaspersoft/ Jasperreports: How to pass parameter list to IN clause? [duplicate]

This question already has answers here:
passing SQL "IN" parameter list in jasperreport
(3 answers)
Closed 3 years ago.
I cannot make it work with ${P} and passing and string with "'parameter1',"parameter2'" form.
Thanks!
I've found that this can be achieved with:
SELECT COLUMN1
FROM TABLE
WHERE $X{IN, COLUMN1, parameterList}
Then parameter list has to be a Java Collection and defined as follows:
Jaspersoft list parameter screenshot
Reference: https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-user-guide/v60/using-parameters-queries

Jasper merge cells with same values [duplicate]

This question already has answers here:
How to merge cells in same column, apply rowspan?
(1 answer)
How to hide duplicates values in column
(1 answer)
How to remove repeating row in jasper report
(1 answer)
Closed 5 years ago.
How can I merge cells of a table made by jasper report from database query when cells value are the same.
Example :
Desired behaviour :
Thank you

text size limitation in PgAdmin query [duplicate]

This question already has answers here:
incomplete information from query on pg_views [duplicate]
(2 answers)
Closed 7 years ago.
I want to get the source code of a function in my db.
I run this query:
select proname,prosrc from pg_proc where...
However when I copy the data in the procsrc field it copy only some of the function code, the whole code is not shown. I suspect that somewhere in the preference there is a text size limit.
How do I fix it?
Character Types
Text type has unlimited length. There are another problem.
Or try to change Max characters per column option.
File > Options > Query Tool > Max. characters per column
Max characters per column - Use the Max characters per column field to
specify the maximum length of data displayed in a single column.