Skip to main content

All Questions

Tagged with
-4 votes
0 answers
25 views

MS SQL - Detecting users with consecutive weeks [closed]

I need to detect consecutive weeks that a user appears within a table, with obviously no gaps in between weeks, I have the below solution which is based upon an answer here... https://stackoverflow....
Matthew Stott's user avatar
1 vote
1 answer
25 views

Filter filtered bike prices twice without repeating yourself

dbfiddle Goal Without repetition in the code, I want to filter BikeValuationList to only give the BikePriceId of the latest ...
J. Mini's user avatar
  • 127
0 votes
0 answers
19 views

Calendar Table in Power BI

I've been reusing calendar tables in various formats for a few years now. I'd like to know best practices and if there are ways to improve them. Any suggestions for style, code, etc. are all welcome. ...
aduguid's user avatar
  • 490
3 votes
2 answers
104 views

Calculate the count of top performers in SQL

I have a transaction table let's call it Offers Table. Please don't read too much into the business but let's say a customer wants to buy a car and the customer searches variety of websites but at the ...
Cody's user avatar
  • 31
2 votes
1 answer
71 views

Find All Recent Winners and Calculate an Encoding of What They Won

Context I was proud of this code for a little while, but the repetition wounds me. I know that the function name sucks, but the name and interface to this function are not under my control. ...
J. Mini's user avatar
  • 127
2 votes
2 answers
86 views

Find All Recent Winners and Calculate an Encoding

Context I was proud of this code for a little while, but the repetition wounds me. I know that the function name sucks, but the name and interface to this function are not under my control. ...
J. Mini's user avatar
  • 127
1 vote
1 answer
131 views

What is the percentage of customers who increase their closing balance by more than 5%?

The Question What is the percentage of customers who increase their closing balance by more than 5%? Source Code The database and all details can be found here. ERD My Proposed Solution ...
Mike's user avatar
  • 113
0 votes
1 answer
116 views

Is there a more concise way to write this Procedure

I have this stored Procedure that is passed in the data below that will building the SQL select that will get EXEC. The data that can be passed in can me null so I have three ...
Jefferson's user avatar
  • 353
1 vote
1 answer
71 views

Is there a more concise way to write this query in SQL Server?

I'm playing with data from a Time Use survey as a beginner SQL user. Gender is represented as 1's (Male) and 2's (Female), and the age of each participant is listed. I would like to divide them into ...
Erik's user avatar
  • 303
0 votes
1 answer
162 views

Count how many active and inactive users are in a group/unit/department/team

Given the following example data: id username group unit department team status 1 user1 g1 u1 d1 t1 active 2 user2 g1 u1 d1 t2 active 3 user3 g1 u1 d1 t3 inactive 4 user4 g3 u6 d12 t30 active 5 ...
pileup's user avatar
  • 421
-2 votes
1 answer
56 views

Optimizing a TRANSACT SQL statement [closed]

I'm in need to optimize the following TRANSACT SQL statement : ...
Simone Spagna's user avatar
3 votes
0 answers
47 views

SQL query to pivot table into dynamically growing set of columns

I am working on SQL Server I have sample data like this in a table. CustId Bank city rating date rnk 1 Deutsche Delhi 5 10/10/2022 1 1 BOA Pune 6 10/10/2022 2 1 UBS Mumbai 7 10/10/2022 3 1 SBI ...
user3580341's user avatar
0 votes
1 answer
58 views

Nested table in query

I have transaction tables called MaterialRequest and MaterialRequestDetails. What I want to check my query and review that it's ...
Basit Sarguroh's user avatar
0 votes
1 answer
51 views

Find dogs who stopped being good boys without ever being good boys - Was HAVING the wrong approach?

The problem I have solved is as follows: Consider a table of dogs, DOGGIES, that records on each row the ID of a doggy, one ...
J. Mini's user avatar
  • 127
-2 votes
1 answer
52 views

T-SQL Query Performance [closed]

The query below already has indexes based its execution plan but it is still under performant with larger datasets. Are the additional null checks needed and why? Do you see anything that can be done ...
Rick B.'s user avatar
  • 135

15 30 50 per page
1
2 3 4 5
14