30 Mayıs 2013, PERŞEMBE
SQL server : bir sorguda 0 Yerine NULL
Bu sorgu , şimdi BOŞ geldiğim ilk threee sütunlar için sonuçlar geliştirdim, nasıl sıfır ile değiştirebilirsiniz ben '0' mı?
Select c.rundate,
sum(case when c.runstatus = 'Succeeded' then 1 end) as Succeeded,
sum(case when c.runstatus = 'Failed' then 1 end) as Failed,
sum(case when c.runstatus = 'Cancelled' then 1 end) as Cancelled,
count(*) as Totalrun from
( Select a.name,case when b.run_status=0 Then 'Failed' when b.run_status=1 Then 'Succeeded'
when b.run_status=2 Then 'Retry' Else 'Cancelled' End as Runstatus,
---cast(run_date as datetime)
cast(substring(convert(varchar(8),run_date),1,4) '/' substring(convert(varchar(8),run_date),5,2) '/' substring(convert(varchar(8),run_date),7,2) as Datetime) as RunDate
from msdb.dbo.sysjobs as a(nolock) inner join msdb.dbo.sysjobhistory as b(nolock)
on a.job_id=b.job_id
where a.name='AI'
and b.step_id=0) as c
group by
c.rundate
CEVAP
30 Mayıs 2013, PERŞEMBE
Başka bir şey null
muhtemelen bir sütun değiştirmek istediğinizde, IsNull kullanın.
SELECT ISNULL(myColumn, 0 ) FROM myTable
Bu ise en başta boş ise sütunum 0 koyacağız.
Bunu Paylaş:
MySQL YERİNE SQL Server 2005 uygulama ...
Neden NULL = NULL SQL server yanlış de...
Nasıl Sql server bir dize null veya bo...
SQL Server Management Studio SSMS için...
Nasıl bir kayıt (select top 1) Her kay...