Skip to main content
edited tags
Link
juergen d
  • 205.3k
  • 40
  • 303
  • 377
Code formatting
Source Link
Andrey Korneyev
  • 26.9k
  • 16
  • 73
  • 72
select  COUNT(Table1.ID) as count_shipped, null as count_shipped   from Table1 where  table1.saleStatus='shipped'  and table1.saleApproved='yes' union select  null, COUNT(Table1.ID) as count_pending   from Table1 where  table1.saleStatus in ('Pending', 'awaiting payment', 'backorder') 

This gives this output

count_shipped count_shipped NULL 5 4 NULL 

but I don't want Null I only want 4 5 in one line Can anybody help me how to do this sql server?

select COUNT(Table1.ID) as count_shipped,null as count_shipped from Table1 where table1.saleStatus='shipped' and table1.saleApproved='yes' union select null,COUNT(Table1.ID) as count_pending from Table1 where table1.saleStatus in ('Pending', 'awaiting payment', 'backorder') 

This gives this output

count_shipped count_shipped NULL 5 4 NULL 

but I don't want Null I only want 4 5 in one line Can anybody help me how to do this sql server?

select  COUNT(Table1.ID) as count_shipped, null as count_shipped   from Table1 where  table1.saleStatus='shipped'  and table1.saleApproved='yes' union select  null, COUNT(Table1.ID) as count_pending   from Table1 where  table1.saleStatus in ('Pending', 'awaiting payment', 'backorder') 

This gives this output

count_shipped count_shipped NULL 5 4 NULL 

but I don't want Null I only want 4 5 in one line Can anybody help me how to do this sql server?

edited title
Link
Jeroen Mostert
  • 29k
  • 2
  • 60
  • 92

can anybody help me how to do this in sql server? Combining rows with NULL columns

Updated formatting
Source Link
krivtom
  • 25k
  • 10
  • 53
  • 54
Loading
added 38 characters in body
Source Link
juergen d
  • 205.3k
  • 40
  • 303
  • 377
Loading
Source Link
Loading