Skip to content
Advertisement

Tag: sql-server

Select in a select from another table [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 6 months ago. Improve this question I need to make a query to another table and add the result

Count rows within date range with condition

I’m not sure that this issue can be solved in SQL server, but I decided to ask you anyway. Let’s create a table and add some random variables: Now, let’s add to the table two columns: “before_5” – five minutes before the given timestamp “after_5” – five minutes the given timestamp Now our table looks in the following way: timestamp

SQL case expression divide values for percentage

I’m trying to divide two values to get the percentage. I need the ‘VA’ AUM / ‘TOTAL’ AUM to get the percentage. Below are the two different methods that I have tried, but they are not providing the percentage. The first method only provides ‘NULL’. How do I take the product of ‘VA’ and the AUM field value and divide

How to check consecutive values in rows in TSQL?

I have the following table: And I am looking for an output like this with a consecutive available two slots. Preferably the consecutive number should be a variable like @n = 2. How to achieve this in TSQL? Thanks! Update 8/3/2022: I undeleted this question as it is not fair to @lptr, as he/she has the correct solution, but didn’t

Consolidate Rows with SQL

Trying to consolidate test results so that each test is in one row. Database I am pulling from has an answer result per row. Sample Data: Student Name Test Name Question Attempt Answered Correctly (0 = no, 1= yes) Mary Intro Assessment 1 1 Mary Intro Assessment 1 0 Mary Intro Assessment 1 1 Joseph Intro Assessment 1 1 Joseph

Advertisement