Skip to content

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 ne…

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 mi…

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 p…

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 Asses…