Skip to content

Tag: sql

Difference between delete statements

vs. Answer The logical conditions of the two statements are different. The first statement will delete any row in TableA if both it’s Field1 and Field2 correspond to the equivalent columns of a row in TableB. The second statement will delete any row in TableA if the value of Field1 exists in Field1 of T…

Best way to filter data for a given range

I need to find Claims from a given table having a procedure code between the range ‘Q5000’ and ‘Q5090’. I am able to write a function for Int codes but am not sure how to best deal with characters range in SQL Server? I can manually write all the codes and filter them but is there any …

Sql Query with NOT LIKE IN WHERE CLAUSE

I have two tables emails and blockedSender I am trying to remove blocked sender from the email query. e.g. emails table: user_id from_address 1 name-1 <email-1@address.com> 2 name-2 <email-2@address.com> blockedSender table: blocked_address email-1@address.com Here I want to return all elements fr…

I didn’t true use order by in linq

Hi i develop web app with c#. I have sql query and i convert to linq but it’s not working true because of order by My sql query My linq Answer Here’s how you can do the order by on the count of each group and take the 3 with the highest count.

SELECT rows with MAX id minus 1 with group by

I have a table with id, city_id, and stock which looks like this. id city_id stock 1 1 1000 2 2 500 3 3 11000 4 2 600 5 3 12000 6 1 2000 9 3 13000 10 1 3000 11 1 4000 12 2 700 To select the latest stock values for each city_id I used the following query,