Skip to content

Tag: sql-server

Compare items in a SQL column with array

I have a SQL server table where I want to query for items on rows which have a value equal to an item in Array. Here’s my example: And my array: So, I want to return from SQL rows matching items in the array. my SQL query should return items where column1 matches an item in the array: This all

How to compare records in a SQL Table

I have a table name TransactionTable. If InsuranceCode = ‘ADAP’ and IsADAP = 1, I have to filter these records and return the remaining records. I am trying to write something similar to this syntax. Total records in TransactionTable is 1832 and Total records on filtration criteria is 109. I expec…

SQL SERVER Insert Addition?

So this seems like something that should be easy. But say I had an insert: and I wanted X to go from 1-100. (Knowing there are some of those numbers that already exist, so if the insert fails I want it to keep going) how would I do such a thing? Answer Here’s a slightly faster way

SQL select from inner join where count greater than

Doctor doctorid (PK) doctorname Patient patientid (PK) patientname doctorid I have the following query to get the doctors details with the number of patients that he/she consults. assume a patient has only one doctor to consult. Now I need to get the same information but only for the doctors who has more than…