[英]PostgreSQL SQL Error [42703]: ERROR: column 'minute' does not exist
[英]PostgreSQL - ERROR: column does not exist SQL state: 42703
我正在嘗試進行群組分析,並根據承租人的第一個租賃年份(= 承租人第一次租賃的年份)比較平均租金數量。 基本上,我在問一個問題:我們是否保留了第一年租金是 2013 年的租戶而不是第一年是 2015 年的租戶?
這是我的代碼:
SELECT renter_id,
Min(Date_part('year', created_at)) AS first_rental_year,
( Count(trip_finish) ) AS number_of_trips
FROM bookings
WHERE state IN ( 'approved', 'aboard', 'ashore', 'concluded', 'disputed' )
AND first_rental_year = 2013
GROUP BY 1
ORDER BY 1;
我得到的錯誤信息是:
ERROR: column "first_rental_year" does not exist
LINE 6: ... 'aboard', 'ashore', 'concluded', 'disputed') AND first_rent...
^
********** Error **********
ERROR: column "first_rental_year" does not exist
SQL state: 42703
Character: 208
任何幫助深表感謝。
SELECT renter_id,
Count(trip_finish) AS number_of_trips
FROM (
SELECT renter_id,
trip_finish,
Min(Date_part('year', created_at)) AS first_rental_year
FROM bookings
WHERE state IN ( 'approved', 'aboard', 'ashore', 'concluded', 'disputed' )
) T
WHERE first_rental_year = 2013
GROUP BY renter_id
ORDER BY renter_id ;
錯誤:
SQL 錯誤 [42703]:錯誤:XYZ 列不存在
檢查列字段周圍是否有雙引號:
壞的:
update public."AppTime" t Set "CustomTask"= 'XYZ' where t.SharedAppId = 12890;
好的:
在“SharedAppId”周圍加上雙引號
update public."AppTime" t Set "CustomTask"= 'XYZ' where t."SharedAppId" = 12890;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.