1

selectステートメントがあります

  select 
  name
  ,age
  from table_employees
  where id=@impId;

ゼロを返すよりも年齢がnullかどうかを確認したい。私はフォローしようとしましたが、うまくいきません

     select 
     name
     ,age isnull(age,0.00)
     from table_employees
     where id=@impId;

これを修正する方法を教えてください。ありがとう

4

7 に答える 7

1

これを試すことができます:-

select 
    name
,   COALESCE(age,0) as age
from table_employees
where id=@impId;
于 2013-09-10T17:51:11.363 に答える
1

見過ごされがちな COALESCE を提案します。

select 
   name, 
   coalesce(age, 0.00) as age_not_null 
from table_employees 
where id = @impId;
于 2013-09-10T17:51:32.823 に答える
0

ISNULL is the statement for SQL Server. You can't put the column name before it.

So, try this:

SELECT name, ISNULL(age,0.00) AS age
FROM table_employees
WHERE id=@impId;
于 2013-09-10T18:03:23.703 に答える
0

以下を試してください:

 select 
 name
 ,isnull(age,0.00)
 from table_employees
 where id=@impId;
于 2013-09-10T17:48:50.003 に答える
0

試す:

 SELECT name,isnull(age,0) 
 FROM table_employees
 WHERE id=@impId;
于 2013-09-10T17:49:04.957 に答える