In SQL server 2008r2, i want to display only lines where some columns are not equal to '0'
For example: I want to display only lines where columns 2 and 3 are <> '0'
line 1 : val1 = 2, val2 = 2, val3 = 0
line 2 : val1 = 1, val2 = 0, val3 = 0
line 3 : val1 = 0, val2 = 0, val3 = 5
line 4 : val1 = 10, val2 = 0, val3 = 3
line 5 : val1 = 0, val2 = 0, val3 = 0
In this example, i want to display lines 1,3,4 but not lines 2 and 5 because both columns 2 & 3 are = '0'
I tried with NOT EXISTS
but it didn't work.
EDIT : Hi, i think it's difficult for me to explain clearly what i want, i put you my definitive request, perhaps you could define my need ^^ :
select * from CONSULTANT inner join REPORTINGCONSULTANT on CONSULTANT.ID = REPORTINGCONSULTANT.FK_CONSULTANT where [CONSULTANT].[ISDESACTIVE] = '0' and [CONSULTANT].[ISSUPPRIME] = '0' and [CONSULTANT].[INITIALES] not like 'IL%' and [REPORTINGCONSULTANT].[DATEDEBUT] >= '02/06/2014' and [REPORTINGCONSULTANT].[NBCANDIDATSPUSH] <> '0' and [REPORTINGCONSULTANT].[NBCVENVOYESURPOSTE] <> '0' and [REPORTINGCONSULTANT].[NBRDVPROSPECTS] <> '0' and [REPORTINGCONSULTANT].[NBRDVCLIENTS] <> '0' and [REPORTINGCONSULTANT].NBPROSPECTSRENCONTRES] <> '0' and [REPORTINGCONSULTANT].[NBPROSPECTSRENCONTRESBINOME] <> '0' and [REPORTINGCONSULTANT].[NBCLIENTSRENCONTRES] <> '0' and [REPORTINGCONSULTANT].[NBCLIENTSRENCONTRESBINOME] <> '0'
When i run only the begining (stop after the date), it counts me 1700 results If i run the rest, it counts me 0 result
but i can find lines where all lines are true
sign(abs(x))
.SELECT t.*
FROM dbo.TableName t
WHERE sign(abs(val1))+sign(abs(val2))+sign(abs(val3)) >1
It implements the requirement of :
display only lines where some columns are not equal to '0'
If "some" means val2 and val3, it could be:
SELECT t.*
FROM dbo.TableName t
WHERE sign(abs(val2))+sign(abs(val3)) >0
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다