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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sorry other problem

Author  Topic 

BrOkEn_iCe
Starting Member

25 Posts

Posted - 2010-06-27 : 04:37:51
i get an error when i try to run this query in the line of is null

so what is the wrong



SELECT
customers.comp_id, ctrl.comp_name, customers.section_code,
locations.location_name AS section_name, customers.branch_code,
locations_2.location_name AS branch_name, customers.group_code,
locations_1.location_name AS group_name, customers.cust_address,
customers.file_no, customers.cust_name,
(CASE WHEN ([meter_status_code]=1 Or IsNull(([meter_status_code],1))) THEN 1 ELSE 0 END) AS mtr_1,
(CASE WHEN ([meter_status_code]=2) THEN 1 ELSE 0 END) AS mtr_2,
(CASE WHEN ([meter_status_code]=3) THEN 1 ELSE 0 END) AS mtr_3,
(CASE WHEN ([meter_status_code]=4) THEN 1 ELSE 0 END) AS mtr_4,
(CASE WHEN ([meter_status_code]=5) THEN 1 ELSE 0 END) AS mtr_5,
(CASE WHEN ([meter_status_code]=9) THEN 1 ELSE 0 END) AS mtr_9,
customers.stamp_date, customers.stamp_time, customers.stamp_user, users.user_descr,
customers.meter_status_date, customers.activity_code,
CONVERT(int,([activity_code]/100)) AS main_act,
CONVERT(int,([activity_code]/10000)) AS cust_type
FROM users RIGHT JOIN (ctrl RIGHT JOIN ((locations AS locations_2 RIGHT JOIN (customers LEFT JOIN locations ON customers.section_code = locations.location_code) ON locations_2.location_code = customers.branch_code) LEFT JOIN locations AS locations_1 ON customers.group_code = locations_1.location_code) ON ctrl.comp_id = customers.comp_id) ON users.user_id = customers.stamp_user;

Sachin.Nand

2937 Posts

Posted - 2010-06-27 : 05:09:39
Why have you put so many parenthesis in the null part?Also your null condition is not evalutiing to anything.

(CASE WHEN ([meter_status_code]=1 Or IsNull([meter_status_code],1)=some condition) THEN 1 ELSE 0 END) AS mtr_1,




Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page
   

- Advertisement -