Lijina
Lijina

Reputation: 297

To List All Rows Without Any Null Values

I have A table Named tblMaimtainsHdr,In that I have Columns as Given Below

Sl.no Asset_Id Building_ID MaintainsDate
1      0         1          21/02/2012
2      1         0          22/02/2012
3      2         0          23/02/2012

I want To select the asset_ID and maintainsDate where The asset_ID is Not Null

How To do it

Upvotes: 0

Views: 238

Answers (1)

paxdiablo
paxdiablo

Reputation: 881383

That would be:

select     Asset_Id,
           MaintainsDate
from       tblMaintainsHdr
where      Asset_Id is not null

assuming that tblMaimtaimsHdr (with an m) was a typo :-)


And you should almost always have an order by clause on your selects. Not that it's pertinent to the question, just something I thought I'd mention :-)


If you want to get rows for everything where Asset_Id is neither NULL nor 0 (as per your comment), use:

select     Asset_Id,
           MaintainsDate
from       tblMaintainsHdr
where      Asset_Id is not null
and        Asset_Id <> 0

Upvotes: 1

Related Questions