Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am getting a No predicate warning on this query. Can someone help?

SELECT DISTINCT TOP 100 T0.nsid, 
                        T0.id, 
                        T0.version, 
                        T0.name, 
                        T1.currency, 
                        T0.disbursmentamount, 
                        T0.effectivedate, 
                        T0.enddate, 
                        T0.contractname, 
                        T0.scheduledbillingdate, 
                        T0.dueamount, 
                        T0.paidamount, 
                        T0.cashpaidamount, 
                        T0.paidamount, 
                        T0.writeoffamount, 
                        T0.canceled, 
                        T0.creationdate, 
                        T0.creationtime, 
                        T0.mustbepaidat, 
                        T0.isrebill, 
                        T1.name, 
                        T0.status, 
                        T2.sendtoprint, 
                        T2.isprinted 
FROM   (awfbillingstatementitem T0 
        INNER JOIN awfbusinessaccount T1 
                ON (( ( T0.attachedtoclientaccount_nsid = T1.nsid ) 
                      AND ( T0.attachedtoclientaccount_id = T1.id ) ))) 
       LEFT OUTER JOIN awfbillingstatementitem T2 
                    ON ( ( ( T2.nsid = T0.nsid ) 
                           AND ( T2.id = T0.id ) ) 
                         AND ( T2.h_iskilled = 0 ) 
                         AND ( T2.h_clid = 218169570 ) ), 
       awfcontract T3 
       LEFT OUTER JOIN awfdescversionedbydate T5 
                    ON ( ( ( T3.versionedpolicyowner_nsid = T5.nsid ) 
                           AND ( T3.versionedpolicyowner_id = T5.id ) 
                           AND ( -T3.versionedpolicyowner_version = 
                         T5.version ) ) 
                         AND ( T5.h_iscurvers = 1 ) 
                         AND ( T5.h_iskilled = 0 ) 
                         AND ( T5.h_clid = 234821058 ) ) 
       LEFT OUTER JOIN (awfpolicyownerversion T6 
                        LEFT OUTER JOIN awfdescversionedbydate_versions T8 
                                     ON ( T8.nsid = T6.nsid 
                                          AND T8.id = T6.id 
                                          AND T8.version = -T6.version )) 
                    ON ( T5.nsid = T8.lonsid 
                         AND T5.id = T8.loid 
                         AND T5.versions_version = T8.loversion 
                         AND ( T6.h_iscurvers = 1 ) 
                         AND ( T6.h_iskilled = 0 ) ), 
       awfperson T4 
WHERE  ( ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND (( T0.canceled = 0 )) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND ( 0 = 0 ) 
         AND (( ( T0.contract_nsid = T3.nsid ) 
                AND ( T0.contract_id = T3.id ) )) 
         AND ( 0 = 0 ) 
         AND ( 1 = 1 ) 
         AND ( (( ( T0.client_nsid = T4.nsid ) 
                  AND ( T0.client_id = T4.id ) )) 
                OR (( ( T1.thirdparty_nsid = T4.nsid ) 
                      AND ( T1.thirdparty_id = T4.id ) )) ) 
         AND ( 0 = 0 ) 
         AND ( (( ( T3.subscriber_nsid = T4.nsid ) 
                  AND ( T3.subscriber_id = T4.id ) )) 
                OR (( ( T3.policyowner_nsid = T4.nsid ) 
                      AND ( T3.policyowner_id = T4.id ) )) 
                OR (( ( T6.policyowner_nsid = T4.nsid ) 
                      AND ( T6.policyowner_id = T4.id ) )) ) 
         AND ( 0 = 0 ) ) 
       AND ( T3.h_iscurvers = 1 ) 
       AND ( T4.h_iscurvers = 1 ) 
       AND ( T0.h_iskilled = 0 ) 
       AND ( T3.h_iskilled = 0 ) 
       AND ( T4.h_iskilled = 0 ) 
       AND ( ( T4.h_clid = 234817316 ) 
              OR ( T4.h_clid = 234820248 ) 
              OR ( T4.h_clid = 234816906 ) 
              OR ( T4.h_clid = 234817143 ) 
              OR ( T4.h_clid = 234821693 ) 
              OR ( T4.h_clid = 218169345 ) ) 
ORDER  BY T0.creationdate DESC, 
          T0.creationtime DESC, 
          T0.effectivedate DESC 
share|improve this question

closed as too localized by Nick Chammas, dezso, StanleyJohns, Kin, Paul White Jun 25 '13 at 14:58

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Why on earth do you check 0=0 and 1=1 so many times? –  JNK Jun 24 '13 at 20:56
    
Probably ORM- or application-generated dynamic SQL. –  Jon Seigel Jun 24 '13 at 22:06
    
I assume this is SQL Server code. Is that correct? –  Nick Chammas Jun 25 '13 at 5:40
    
It is a sql server code generated by a vender application –  user2452888 Jun 25 '13 at 17:12
1  
@user2452888 - If you don't provide some explanation for your edit it will probably be rolled back. Does it contain code that you shouldn't have posted? –  Martin Smith Jun 28 '13 at 21:26

1 Answer 1

The error is because of multiple cross joins.

Your joins to T3 and T4 both are CROSS JOINs or cartesian products. You need a join condition, i.e. a way to relate the two tables in order to remove the warning.

share|improve this answer
    
Can you help me replace the cross join ? –  user2452888 Jun 24 '13 at 23:52
    
@user2452888 Well we need to know how the tables are related for that. Right now you are basically asking for every row from table A to be paired up with every row from table B. If it's giving you the results you want, ignore the warning. Otherwise you need to figure out your data. –  JNK Jun 25 '13 at 0:58
    
You can also try replacing the two commas, before awfcontract T3 and before awfperson T4 with CROSS JOIN. –  ypercube Jun 25 '13 at 5:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.