I have a table called SessionEvents. I’m trying to create a column that represents the firmware that is on the machine to later be able to filter messages for only certain software. Currently my SQL query looks like this. (Based on answer by adamlamar in How do I efficiently select the previous non-null…
Tag: sql-server
Return word with the capital letter from string
I have a column like: How to get: Assume there is only one word with the capital letter per string. Answer You would need PATINDEX (to find any of the capital letters within the string), CHARINDEX (to find the position of space after the capital letter or end of the string) and SUBSTRING (to get the part of t…
How to save SQL query analytics in the background while still delivering records to user?
I am interested in knowing if there is an efficient way to record the analytics from a SQL query while still providing the records to the requester? I’m currently on MS SQL Server 2012. Let’s say for …
SQL – Finding foreign key ID associated with a combination of multiple/variable table variable rows
In a Microsoft SQL Server stored procedure, I have table variable, @PlayerComboStrategy, with a variable number of rows, and columns PLAYER_ID, POSITION_CODE, STATUS_CODE. I am looking for the most …
SQL Query to get the compliance status
I’m trying to get the following query constructed I got a table called client_vendor as follows. This stores the details of answers provided by client against a vendor for 4 questions. client_vendor …
Concate string into temp table in cursor
I have a temp table structure @temp2 like this and would like to add the driverID column with a result like 5555, 68989 to do this, I use the cursor to loop another table look like this Here is the code sadly, I got the driverID column is null and would like to have finalized temp table look like this:
Building an Employee Date Matrix
I have a list of employees, along with list of cities they’ve worked in. I need to build a matrix (in SQL Server) of start/end dates by city to determine where they were at any given period in time. The “end date” would be exactly the date before they appeared at a new location. I’ve i…
Check the number of digits or their range
I tried to create a table for save Tradeshows and I need to save Year and Month into different columns. I have a problem with my back-end and front-end developers for check data. I need to check years is 4 number and month between 1-12. Speed is important to me. Answer Just use check constraints: Or, you coul…
SQL & Pandas Efficiency [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago. Improve this question Quick question. What is the rule of thumb when deciding where to begi…
SQL JOIN to select MAX value among multiple user attempts returns two values when both attempts have the same value
Good morning, everyone! I have a pretty simple SELECT/JOIN statement that gets some imported data from a placement test and returns the highest scored attempt a user made, the best score. Users can take this test multiple times, so we just use the best attempt. What if a user makes multiple attempts (say, tak…