Why am I getting this PostgreSQL error on this join...? [closed] - postgresql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
trying to comment out the join fields with this PostgreSQL statement:
select
veh."Truck Name",
veh."Truck Type",
veh.office,
--off.address,
--off.city,
--off.state,
--off.zipcode
from
vehicles veh
--join offices off on veh.office = off.office
order by
veh.office asc;
I get the following error:
SQL Error [42601]: ERROR: syntax error at or near "from"
Position: 180
I want to be able to remove the -- indicators and run the report

just remove comma after veh.office
select
veh."Truck Name",
veh."Truck Type",
veh.office
--off.address,
--off.city,
--off.state,
--off.zipcode
from
vehicles veh
--join offices off on veh.office = off.office
order by
veh.office asc;

Related

Postgresql how to do min and max with the name beside the value [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
this is the data table
how to do to get below result:
Here is the result i want to get
I only can get lowest and highest without (name), any ideas to get above result?
Use GROUP BY for grouping the subjects and then fetch max_mark, min_mark using MAX(), MIN() functions respectively
SELECT subject AS "sub1",
MAX(scc) AS "max_mark",
MIN(scc) AS "min_mark"
FROM Subjects_mark
GROUP BY 1
Now use subquery for formatting the output
SELECT sub1,
CONCAT(min_mark,'(',studentnar,')') AS "lowest point",
CONCAT(max_mark,'(',studentnar,')') AS "highest point"
FROM Subjects_mark AS s1
JOIN (
SELECT subjects AS "sub1",
MAX(scc) AS "max_mark",
MIN(scc) AS "min_mark"
FROM Subjects_mark
GROUP BY 1
) AS dt
ON dt.sub1 = s1.subjects
AND dt.max_mark = s1.scc

Why the "Group BY" by month didn't work? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Why the result of this query is always one :
SELECT stats1.cnt1 FROM staging.memberships_autoship_box b JOIN staging.memberships_autoship a ON a.id = b.autoship_box_id JOIN (SELECT COUNT(bn.autoship_box_id) cnt1,bn.autoship_box_id FROM staging.memberships_autoship_box bn GROUP BY bn.autoship_box_id ) stats1 ON
(stats1.autoship_box_id = a.id)
The group by clause, unlike the order by clause, doesn't take column ordinals. In this clause, 1 and 2 are just integer literals, and since every row of your query has the same value for these two literals, they are all grouped in to a single result row.
Instead, you should use the actual columns from your query:
GROUP BY sql_activity_days.styleship_start_month, memberCountSql."122_days"

newline character in Postgresql [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How can we get this output
results from query should be like:
Assessment
penalty
both values are coming from two different columns. I want to join these two columns but want results like above in single cell. so there should be new line for second column(but in same cell)
select assessment || E'\n' || penalty from wherever
or
select concat_ws(chr(10), assessment, penalty) from wherever
Note: I am assuming, since you didn't say, that neither column can be null.

How to concatenate a query string safely in plpgsql? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
The community reviewed whether to reopen this question 5 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
For example:
Query1
abc:='select * from table1';
Query2
result:='create view'||quote_ident(view1)||'as'||abc;
I'm going to take a wild guess and assume you're trying to use dynamic SQL to create a view.
If so, use the EXECUTE statement.
abc := 'select * from table1';
result := 'create view '||quote_ident(view1)||' as ' || abc;
EXECUTE result;
Your query text looked OK except for the missing spaces, assuming that view1 is a text parameter.
(In future: include PostgreSQL version, exact text of any error message, the full code you're using, etc).

How to select a single quoted column using postgres [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Select COLUMN_name
from TABLE_name
where COLUMN NAME = 'something's'
While executing this query in PostgreSQL, it is showing an error as like below,
syntax error at or near "S".
The apostrophe in KEPLER'S is terminating the string early. Escape it, and proofread next time.
Select CONCEPTNAME from KM_CONCEPT_MAST where CONCEPTNAME='KEPLER''S LAWS OF PLANETARY MOTION'