Skip to content

Tag: where-clause

SQL where clause selecting specific data

In Microsoft SQL, I am trying to select a specific result from a table when available. Otherwise, other data should be retrieved. Giving the scenario tableA contains various fruits. I want to collect apples that are red otherwise, any other colors except for red should be retrieved. I am not sure which approa…

SQL return rows on or after an specific date

I am trying to export a list of member details that have an expiry date after 2019 so I am just after I thought I could simply use the date in a WHERE clause However, it still returns the other entries and not sure why Answer Assuming that you are using SQL Server: dbfiddle

Use one of two dates in where clause

I need to delete all records in a table where the CreatedDate or ModifiedDate is greater than x. The logic is as follows: If ModifiedDate is not null then use this value Otherwise use the CreatedDate value Not applying the if/else statement correctly. Answer Use this where clause: