You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Tableau中编写SQL提取offer_custom_fields表的Vacation Days对应值?

Fixing Your Custom SQL Query for Tableau

Let's get that query working right! The main issue with your current code is the invalid nested WHERE clause inside your condition—SQL doesn't allow that structure. Here's how to fix it, plus an option if you need to join with the offers table as you mentioned.

Basic Corrected Query

If you just need the offer_id and corresponding display_value for the 'Vacation Days' custom field from offer_custom_fields:

SELECT 
    offer_id, 
    display_value AS vacation_days
FROM
    offer_custom_fields
WHERE
    custom_field = 'Vacation Days'

Query with Join to offers Table

Since you noted the two tables are linked via offer_id, here's how to combine them if you need additional data from the offers table (like candidate details, offer dates, etc.):

SELECT 
    o.offer_id,
    ocf.display_value AS vacation_days
    -- Uncomment and add fields from offers as needed:
    -- o.candidate_name, o.offer_date
FROM
    offers o
INNER JOIN
    offer_custom_fields ocf 
    ON o.offer_id = ocf.offer_id
WHERE
    ocf.custom_field = 'Vacation Days'

Key Fixes & Improvements:

  • Removed the invalid nested WHERE clause—we directly check custom_field = 'Vacation Days' in the outer WHERE.
  • Added a column alias (vacation_days) to make the output column name more descriptive.
  • Used table aliases (o for offers, ocf for offer_custom_fields) to simplify the code and avoid column name conflicts.
  • Swapped curly quotes (‘’) for straight single quotes (')—most SQL engines (including those used with Tableau) require straight quotes for string literals.

内容的提问来源于stack exchange,提问作者nick lanta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 10:10:31