Postgresql problem- automatically jumping several queries back

I’m following along with a course so all of the queries they taught as well as notes, custom queries to practice and homework queries are in a single .sql file that I save and reopen as I follow along, I’ve come to the part with Timestamps and mathematical functions.

In the course he uses the command:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>SELECT 0.1 * replacement_cost AS deposit
FROM film;
</code>
<code>SELECT 0.1 * replacement_cost AS deposit FROM film; </code>
SELECT 0.1 * replacement_cost AS deposit
FROM film;

This is where I started encountering problems, this query didn’t work for me so i started googling how to fix it, after not finding the solution I tried the same query from the video again.
Again it did not work and just gave me a syntax error in a previous query a bit up, also when I just type easy queries like ‘SELECT * FROM film’ I keep getting syntax errors in previous lines, the queries that I write do work when I highlight them with my mouse.

This is also happening in a new .sql file, and now it keeps jumping up saying there’s a syntax error in line 27 when I’m trying to write in line 50+

The query the syntax error is occurring(line 27) is ‘SELECT AGE (payment_date) FROM payment;’
However when I highlight it it actually runs the query and shows the expected results

Here is the full text and notes from my second .sql file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>--Timestamps and extract Part One--
--TIME - Contains only time--
--DATE - Contains only date--
--TIMESTAMP - Contains date and time--
--TIMESTAMPTZ - Contains date, time and timezone--
SHOW All
--SHOW TIMEZONE--
--SELECT NOW()--
--SELECT TIMEOFDAY()--
--SELECT CURRENT_TIME--
--SELECT CURRENT_DATE--
--Timestamps and extract Part Two--
--EXTRACT()
--YEAR--
--MONTH--
--DAY--
--WEEK--
--QUARTER--
--EXTRACT(YEAR FROM "date_col")Extract or obtain a sub-component of a date value--
--AGE("date_col")Calculates and returns the current age given a timestamp--
--TO_CHAR()General function to convert date types to text/Timestamp formatting--
--EXAMPLE: TO_CHAR("date_col", 'mm-dd-yyyy') Or other date format--
--This query can work with YEAR,DAY,QUARTER,WEEK,MONTH--
SELECT AGE(payment_date) >>>>>LINE 27 WHERE THE SYNTAX ERROR OCCURS<<<<<
FROM payment;
--You can format freely, ordering D/M/Y, use - or /--
SELECT TO_CHAR(payment_date,'DD-MM-YY') AS Paydate
FROM payment;
--Timestamps and extracts Challenge Tasks--
SELECT DISTINCT TO_CHAR (payment_date, 'Month') AS Paymonth
FROM payment;
SELECT COUNT (TO_CHAR (payment_date, 'dy')) AS days
FROM payment
WHERE TO_CHAR(payment_date,'dy') = 'mon'; --My solution--
SELECT COUNT(*)
FROM payment;
WHERE EXTRACT(dow FROM payment_date)=1; --Course solution--
--Mathematical functions and Operators--
SELECT ROUND(rental_rate/replacement_cost,4)*100 AS percent_cost
FROM film;
</code>
<code>--Timestamps and extract Part One-- --TIME - Contains only time-- --DATE - Contains only date-- --TIMESTAMP - Contains date and time-- --TIMESTAMPTZ - Contains date, time and timezone-- SHOW All --SHOW TIMEZONE-- --SELECT NOW()-- --SELECT TIMEOFDAY()-- --SELECT CURRENT_TIME-- --SELECT CURRENT_DATE-- --Timestamps and extract Part Two-- --EXTRACT() --YEAR-- --MONTH-- --DAY-- --WEEK-- --QUARTER-- --EXTRACT(YEAR FROM "date_col")Extract or obtain a sub-component of a date value-- --AGE("date_col")Calculates and returns the current age given a timestamp-- --TO_CHAR()General function to convert date types to text/Timestamp formatting-- --EXAMPLE: TO_CHAR("date_col", 'mm-dd-yyyy') Or other date format-- --This query can work with YEAR,DAY,QUARTER,WEEK,MONTH-- SELECT AGE(payment_date) >>>>>LINE 27 WHERE THE SYNTAX ERROR OCCURS<<<<< FROM payment; --You can format freely, ordering D/M/Y, use - or /-- SELECT TO_CHAR(payment_date,'DD-MM-YY') AS Paydate FROM payment; --Timestamps and extracts Challenge Tasks-- SELECT DISTINCT TO_CHAR (payment_date, 'Month') AS Paymonth FROM payment; SELECT COUNT (TO_CHAR (payment_date, 'dy')) AS days FROM payment WHERE TO_CHAR(payment_date,'dy') = 'mon'; --My solution-- SELECT COUNT(*) FROM payment; WHERE EXTRACT(dow FROM payment_date)=1; --Course solution-- --Mathematical functions and Operators-- SELECT ROUND(rental_rate/replacement_cost,4)*100 AS percent_cost FROM film; </code>
--Timestamps and extract Part One--
--TIME - Contains only time--
--DATE - Contains only date--
--TIMESTAMP - Contains date and time--
--TIMESTAMPTZ - Contains date, time and timezone--
SHOW All

--SHOW TIMEZONE--
--SELECT NOW()--
--SELECT TIMEOFDAY()--
--SELECT CURRENT_TIME--
--SELECT CURRENT_DATE--

--Timestamps and extract Part Two--
--EXTRACT()
--YEAR--
--MONTH--
--DAY--
--WEEK--
--QUARTER--
--EXTRACT(YEAR FROM "date_col")Extract or obtain a sub-component of a date value--
--AGE("date_col")Calculates and returns the current age given a timestamp--
--TO_CHAR()General function to convert date types to text/Timestamp formatting--
--EXAMPLE: TO_CHAR("date_col", 'mm-dd-yyyy') Or other date format--
--This query can work with YEAR,DAY,QUARTER,WEEK,MONTH--

SELECT AGE(payment_date) >>>>>LINE 27 WHERE THE SYNTAX ERROR OCCURS<<<<<
FROM payment;
--You can format freely, ordering D/M/Y, use - or /--
SELECT TO_CHAR(payment_date,'DD-MM-YY') AS Paydate
FROM payment;
--Timestamps and extracts Challenge Tasks--

SELECT DISTINCT TO_CHAR (payment_date, 'Month') AS Paymonth
FROM payment;

SELECT COUNT (TO_CHAR (payment_date, 'dy')) AS days
FROM payment
WHERE TO_CHAR(payment_date,'dy') = 'mon'; --My solution--

SELECT COUNT(*)
FROM payment;
WHERE EXTRACT(dow FROM payment_date)=1; --Course solution--

--Mathematical functions and Operators--
SELECT ROUND(rental_rate/replacement_cost,4)*100 AS percent_cost
FROM  film; 

It’s mostly notes and queries, but they all end with ; and it just keeps jumping back up with an error syntax in line 27

In my big .sql file where the entire course is written in I’ve also encountered the ‘current transaction is aborted, commands ignored until end of transaction block’ error, which is what prompted me to start in a new file.

How do I prevent this from happening?

Thanks!

New contributor

Stefan Wolters is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật