Syntax Rommel
Syntax Rommel

Reputation: 942

Get necessary output from view

I am trying to query from view to remove the row that has null values on column value if only the column name has duplicate row count.

So here is my sample result from my view and what I expect is the highlighted row should not be in the result, just want to have recommendation and suggestion how can I easily remove that highlighted row using query because right now I am removing through my application code.

Select * from TblView1

enter image description here

Upvotes: 1

Views: 30

Answers (1)

Tomaso Albinoni
Tomaso Albinoni

Reputation: 1013

If I understand the question correctly, you want to:

  • Include all rows with a unique Name
  • Include rows without null for rows with non-unique Names

I believe this should work:

select * from TblView1 where Name in
    (select Name from TblView1 group by Name having count(*) = 1)
or location is not null

Upvotes: 2

Related Questions