Recursive SELECT query to return rates of arbitrary depth?
问题 This is my first time attempting a recursive SQL query to traverse N parent-child relationships upward, and I don't know where to start. Any help would be appreciated. Scenario is that I have two tables - rate and rate_plan . Rates belong to a rate plan which is applied to a user. CREATE TERM rate_plan ( id integer PRIMARY KEY NOT NULL DEFAULT nextval('rate_plan_id'), descr varchar(64) NOT NULL, parent_rate_plan_id integer NOT NULL REFERENCES rate_plan(id) ); CREATE TABLE rate ( id integer