Skip to content
Advertisement

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 approach to go with, having a Case Statement

Using a subquery in a case statement in a where clause

I want to select different results (from a temp table) based on what a certain parameter is set to in the query. I want to exclude certain inventory SKUs if a particular warehouse is selected. I am getting this error, unfortunately. Msg 512, Level 16, State 1, Line 310 Subquery returned more than 1 value. This is not permitted when

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:

Advertisement