Syntax error at end of input in PostgreSQL
You haven't provided any details about the language/environment, but I'll try a wild guess anyway:
MySQL's prepared statements natively use ?
as the parameter placeholder, but PostgreSQL uses $1
, $2
etc. Try replacing the ?
with $1
and see if it works:
WHERE address = $1
The error messages in PostgreSQL are very cryptic.
In general, I've found that Postgres error messages are better than competing products (ahem, MySQL and especially Oracle), but in this instance you've managed to confuse the parser beyond sanity. :)
Postgres showing Error: syntax error at end of input
You must close the parentheses when creating the table
# create table in ebi_mut_db schema
cursor.execute("""
CREATE TABLE IF NOT EXISTS ebi_mut_db.version_info(
version INT,
download_date DATE,
download_url text,
responsible text)
""")
PostgresQL Syntax Error at end of input, how do I troubleshoot this?
I suspect that you want the total companies, the companies with non-NULL values for a column and the ratio.
If so, this has nothing to do with distinct
:
SELECT COUNT(*),
COUNT(funding_total_usd) as num_with_funding,
AVG( (funding_total_usd IS NOT NULL)::int ) as ratio_with_funding
FROM tutorial.crunchbase_companies;
Related Topics
Row-Level Trigger VS Statement-Level Trigger
Sql: Alias Column Name for Use in Case Statement
Regular Expression to Match All Comments in a T-SQL Script
Postgresql Where Count Condition
SQL Server: Use Parameter in Create Database
How to Use If/Else Statement to Update or Create New Xml Node Entry in SQL
How Universal Is the Limit Statement in SQL
Check If Null Exists in Postgres Array
Using Alias in When Portion of a Case Statement in Oracle SQL
How to Find Out What Is Locking My Tables
SQL - Call Stored Procedure for Each Record
How to Group by Time Interval in Spark SQL
SQL Server Unique Composite Key of Two Field with Second Field Auto-Increment
"Select Distinct" Ignores Different Cases
Scope_Identity VS Ident_Current
Using Ssis to Extract a Xml Representation of Table Data to a File