SSRS - SELECT 语句中的错误消息

SSRS - Error message in SELECT Statement

有没有办法重写此 SELECT 查询以避免错误? 每当我 运行 下面的查询时,我都会收到此错误消息: "An expression of non-boolean type specified in a context where a condition is expected, near ';'. Incorrect syntax near 'LoanAmountGroup'. Incorrect syntax near 'LoanAmountGroupOrder'."

SELECT DISTINCT 
   CASE WHEN LoanAmnt & lt; = 100000 THEN 'Less Than 0k' 
        WHEN LoanAmnt BETWEEN 100000 AND 200000 THEN '0k to 0k' 
        WHEN LoanAmnt & gt;200000 THEN 'More Than 0k' 
    END LoanAmntGroup, 
    CASE WHEN LoanAmnt & lt; = 100000 THEN 1 
        WHEN LoanAmnt BETWEEN 100000 AND 200000 THEN 2 
        WHEN LoanAmnt & gt; 200000 THEN 3 
    END LoanAmntGroupOrder

FROM    dbo.Fact_Finance
ORDER BY LoanAmntGroupOrder

我正在使用 SQL 管理器

你需要删除 & lt;<& gt; for > 在你的 query.You 可以试试你的查询,

    SELECT DISTINCT 
         CASE WHEN LoanAmnt <= 100000 THEN 'Less Than 0k' 
              WHEN LoanAmnt BETWEEN 100000 AND 200000 THEN '0k to 0k' 
              WHEN LoanAmnt > 200000 THEN 'More Than 0k' 
         END LoanAmntGroup, 
        CASE WHEN LoanAmnt <= 100000 THEN 1 
             WHEN LoanAmnt BETWEEN 100000 AND 200000 THEN 2 
             WHEN LoanAmnt > 200000 THEN 3 
        END LoanAmntGroupOrder
    FROM    dbo.Fact_Finance
    ORDER BY LoanAmntGroupOrder