postgresql - 尝试去 。在输出期间将值转换为名称
问题描述
列中返回的值a.user_id
是 ID 号。我想将它们作为名称或首字母返回,例如 1 = Chris O 或 C.ONeill
我尝试过 CASE 功能,但不知道放在哪里
SELECT DISTINCT
sb.start_time::date AS shift_date,
i.title AS industry,
wl.name AS venue_name,
w.first_name,
w.last_name,
MIN(cs.start_time::date) AS first_completed_shift,
i.title AS industry,
w.interviewed_on AS induction_date,
d.issue_date AS edbs_issue_date,
d.created_at AS date_dbs_added,
a.user_id --IS IT POSSIBLE TO GET THESE AS VALUES,e.g. a.user_id '1' = 'Chris O or C.ONeill' USING USER NAMES INSTEAD OF USER ID?
FROM shift_bookings sb
JOIN jobs j ON sb.job_id = j.id
JOIN listings l ON j.listing_id = l.id
JOIN work_locations wl ON l.venue_id = wl.id
JOIN workers w ON sb.worker_id = w.id
JOIN completed_shifts cs ON w.id = cs.worker_id
JOIN documents d ON w.id = d.documentable_id
JOIN audits a ON d.id = a.auditable_id
JOIN industries i ON j.industry_id = i.id
WHERE sb.shift_id IN (253106)
AND d.document_type_id = 33
AND a.auditable_type = 'Document'
GROUP BY
sb.start_time::date,
wl.name,
w.first_name,
w.last_name,
i.title,
w.interviewed_on,
d.issue_date,
d.created_at,
a.user_id
a.user_id 输出将是我可以设置的其他内容
解决方案
推荐阅读
- python - Python excel下拉过滤器不适用于openpyxl或xlsxwriter
- javascript - Laravel:给 longText 字段一个默认值
- amazon-web-services - 如何找出哪个日志组的 CloudWatch GetMetricData 成本?
- python - 熊猫:groupby 使用 numba 申请
- java - 无法找到请求目标的有效证书路径,尝试通过 https 请求使用 SMS api
- java - 如何永久更改 Jtable 的值?
- java - Java Spring:尝试通过xml配置webflow,找不到dispatcher-servlet.xml
- c# - 实例化的预制件没有按预期工作,但是当预制件放在现场时,一切都按预期运行
- provisioning - SCIM 可以更新非 SCIM 创建的资源吗?
- java - 如何在 Mobile Native 中使用 Java 和 Appium 处理 iOS App 会话超时