I have a query like this
SELECT "source"."User Profile__user_type", case when "User Profile__user_type" = 4 then cast("User Profile__user_type" as text)="BUILDER" end AS "User Profile__user_type", sum("source"."totalPrice") AS "sum"
FROM (SELECT "public"."master_order"."id" AS "id","public"."master_order"."totalPrice" AS "totalPrice", "public"."master_order"."status" AS "status", "User Profile"."user_id" AS "User Profile__user_id", "User Profile"."user_type" AS "User Profile__user_type"
FROM "public"."master_order" FULL JOIN "django_db_schema"."user_profile" "User Profile" ON "public"."master_order"."orderedBy"::uuid = "User Profile"."user_id"
WHERE ("public"."master_order"."status" = 1 OR "public"."master_order"."status" = 8)
LIMIT 1048575) "source"
GROUP BY "source"."User Profile__user_type"
ORDER BY "sum" ASC, "source"."User Profile__user_type" ASC
In this query I have "User Profile__user__type" as an int here if its an int of 4 I want the output to have a label as "Builder" but Im getting this error
SQL Error [42703]: ERROR: column "BUILDER" does not exist
Position: 130
Error position: line: 1 pos: 129
Breaking my head over this since a few days help is appreciated