请帮我解决我的查询中的错误。如何在这里使用合并。 [英] please help me to solve the errors in my query.How to use coalesce here.

查看:49
本文介绍了请帮我解决我的查询中的错误。如何在这里使用合并。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select A.int_ApplicantId,A.vch_UniqueRefNo,A.vch_ApplicantName,case int_Gender when 1 then 'Male' when 2 then 'Female'  end as Gender,vch_CorHouseNo,(select vch_DistrictName from M_District where int_DistrictID=A.int_CorDistID   and int_StateID=A.int_CorStateID)District,vch_CorPinCode,dtm_DOB, (case int_CategoryId when 1 then 'UR' when 2 then    'SC' when 3 then 'ST' when 4 then 'SEBC' end)Category, (case isnull(bit_PHOH,0) when 1 then 'Yes' else 'No' end ) PWD,(case isnull(bit_SportsPerson,0) when 1 then  'Yes' else 'No' end ) SportsPerson,(case isnull(bit_ESM,0)  when 1 then 'Yes'    else 'No' end ) ESM, (case isnull(bit_Odia,0) when 1 then 'Yes' else 'No' end ) Odia,   (select vch_DDNO from T_Finance_Details F where isnull(F.bit_DeletedFlag,0)=0 and F.vch_uniquerefno=A.vch_uniquerefno)vch_DDNO,A.vch_CorMobileNo,Case Vch_Remarks when Null then( select vch_Remarks from T_CAF_Receive C where C.vch_UniqueRefNo=A.vch_UniqueRefNo and ISNULL(c.bit_DeletedFlag,0)=0 )
   else  coalesce(select  vch_remarks From M_Remark_Detail where
     int_Remark_id in(Select val from UDF_Split(Select vch_Remarks from T_Caf_Receive C
     where C.vch_UniqueRefNo=A.vch_UniqueRefNo)),+',','') end As Remarks
    (case isnull(A.bit_ReceiveStatus,0) when 1 then  '1' else '0' end ) ReceiveStatus from T_ApplicantDetails_Temp A  where isnull(A.bit_DeletedFlag,0)=0 and ISNULL(A.bit_ReceiveStatus,0)=1 and ISNULL(A.bit_Rejected,0)=1 and isnull(A.bit_DuplicateStatus,0)=0 and A.vch_AdvertisementNo='2395' and A.vch_Post_Code='35' order by A.vch_UniqueRefNo



错误是消息156,等级15,状态1,行2

关键字'select'附近的语法不正确。

消息156,等级15,状态1,第3行

关键字选择附近的语法不正确。

消息102,级别15,状态1,行4

语法不正确靠近')'。


error are Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'select'.
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'Select'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ')'.

推荐答案

请使用此网站格式化您的脚本和改善你的问题。
Please use this site to format your script and improve your question.


太多 SELECT 了!零 JOIN 's!



您的SQL查询非常糟糕,即使正确的格式化也无济于事,抱歉;(



我建议从基础开始: SQL Tutorial [ ^ ]并将焦点移至加入 [ ^ ]声明。使用JOIN [ ^ ]您可以使用以下几个表链接数据主键 [ ^ ]和外键 [ ^ ]。

换句话说,当你知道什么是关系数据库 [ ^ ],您将能够创建正确的sql语句。
Too many SELECT's! Zero JOIN's!

Your SQL query is really bad, even proper formatting won't help, sorry ;(

I'd suggest to start with basics: SQL Tutorial[^] and move your focus to JOIN[^] statement. Using JOINs[^] you're able to link data from several tables using Primary Key[^] and Foreign Key[^].
In other words, when you'll know what is Relational Database[^], you'll be able to create proper sql statement.


这篇关于请帮我解决我的查询中的错误。如何在这里使用合并。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆