Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
alperozgur
Starting Member
16 Posts |
Posted - 2004-12-08 : 01:24:06
|
| Hi;i have a query as belows. My problem is i want my query checking the red colored conditions but not getting the records that agrees with the condition, only checking it. how can i do that? Query:DECLARE @Today_date int, @Musteri_Turu char(3), @Odeme_tipi char(2)set @Today_date=(SELECT REPLACE(CONVERT(char(12), GETDATE(), 112),'/',''))set @Musteri_Turu='MA%'set @Odeme_tipi='HH' SELECT A.ADD_CODE AS CARI_HESAP_KODU, PAYMNT_DAY AS ODEME_GUNU, DUE_DATE AS VADE, datediff(day,(select dbo.[IntToDateTime](DUE_DATE)),(select dbo.[IntToDateTime](@Today_date))) AS GUN_FARKI,AMOUNT AS TUTAR, A.ANAL_A4 AS VADE_KATEGORI, ANAL_T0 AS WHO ,DESCRIPTN AS ACIKLAMA INTO #TEMP1 FROM SALFLDGBPT L (NOLOCK) INNER JOIN SSRFACC A (NOLOCK) ON A.ACCNT_CODE=L.ACCNT_CODE AND A.SUN_DB='BPT' JOIN SSRFADB ZZ (NOLOCK) ON L.ACCNT_CODE=ZZ.ACCNT_CODE AND ZZ.ANAL_C7<>'4' AND ZZ.SUN_DB='BPT' WHERE L.ACCNT_CODE LIKE '120%' AND A.ADD_CODE LIKE @Musteri_Turu AND DUE_DATE>0 AND ALLOCATION IN (' ','5') AND DUE_DATE < @Today_dateSELECT * FROM #TEMP1 ORDER BY 1,3,4DROP TABLE #TEMP1 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-08 : 01:28:16
|
| place it on the where part of the query or use case--------------------keeping it simple... |
 |
|
|
alperozgur
Starting Member
16 Posts |
Posted - 2004-12-08 : 01:30:49
|
| How? |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-08 : 02:25:57
|
quote: Originally posted by alperozgur Hi;i have a query as belows. My problem is i want my query checking the red colored conditions but not getting the records that agrees with the condition, only checking it. how can i do that? Query:DECLARE @Today_date int, @Musteri_Turu char(3), @Odeme_tipi char(2)set @Today_date=(SELECT REPLACE(CONVERT(char(12), GETDATE(), 112),'/',''))set @Musteri_Turu='MA%'set @Odeme_tipi='HH' SELECT A.ADD_CODE AS CARI_HESAP_KODU, PAYMNT_DAY AS ODEME_GUNU, DUE_DATE AS VADE, datediff(day,(select dbo.[IntToDateTime](DUE_DATE)),(select dbo.[IntToDateTime](@Today_date))) AS GUN_FARKI,AMOUNT AS TUTAR, A.ANAL_A4 AS VADE_KATEGORI, ANAL_T0 AS WHO ,DESCRIPTN AS ACIKLAMA INTO #TEMP1 FROM SALFLDGBPT L (NOLOCK) INNER JOIN SSRFACC A (NOLOCK) ON A.ACCNT_CODE=L.ACCNT_CODE AND A.SUN_DB='BPT' JOIN SSRFADB ZZ (NOLOCK) ON L.ACCNT_CODE=ZZ.ACCNT_CODE WHERE L.ACCNT_CODE LIKE '120%' AND A.ADD_CODE LIKE @Musteri_Turu AND DUE_DATE>0 AND ALLOCATION IN (' ','5') AND DUE_DATE < @Today_dateAND ZZ.ANAL_C7<>'4' AND ZZ.SUN_DB='BPT'SELECT * FROM #TEMP1 ORDER BY 1,3,4DROP TABLE #TEMP1
actually the question is vague, when you join the tables, you're not selecting them until you specify in your select statement, you are "testing" the conditions, if the conditions on the join are met then you can retrieve some records.--------------------keeping it simple... |
 |
|
|
alperozgur
Starting Member
16 Posts |
Posted - 2004-12-08 : 02:48:26
|
| Thanks but i'm going on to get same problem. I must say that both tables has the same records different details. this may cause the problem |
 |
|
|
|
|
|
|
|