6 votes

Employee Attendance structure design

I would change my parameters to simply require "login" and "logout" timestamps. Then calculate the difference between those two DateTimes. I would move all validation into DI ...
Morten Bork's user avatar
3 votes

Creating an array (temporary table) in SQL and iterating through each row within this table to preform a check on the data in each row

This all needs to be deleted. Roughly, Put your photo sizes into a three-row table with ID, width and height. Ensure that ID is set as a (non-autogenerated) integral primary key. 7190 creeps me out - ...
Reinderien's user avatar
3 votes
Accepted

Is there a more concise way to write this Procedure

Not anything groundbreaking, but I use the template replicate(myString,aFlag) to decide to include a string or not. Also, you don't really need the ...
George Menoutis's user avatar
2 votes
Accepted

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

I agree with you that we could DRY up those CASE statements a bit. The core issue is we would like to report against a relation that does not exist yet, so we must synthesize it. Several approaches ...
J_H's user avatar
  • 25.5k
2 votes

Apply placeholders to an array in a loop for pdo statements for search functions with unknown numbers of keywords

While the other answer is mostly dwelling on the abstract topics, I will concentrate on the practical issues. The idea is very good, and your code is safe from injections. The only issue which bothers ...
Your Common Sense's user avatar
2 votes

Apply placeholders to an array in a loop for pdo statements for search functions with unknown numbers of keywords

Here is the outline that I saw: // please disregard this part. Although functional it is for a lack of sleep. // initial creation of statement // loop to create remainder of statement via place ...
J_H's user avatar
  • 25.5k
2 votes
Accepted

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

Just lump another sub-predicate beside your exists: ...
Reinderien's user avatar
2 votes
Accepted

Find All Recent Winners and Calculate an Encoding

Supply the function with SELECT 0 AS idx, * FROM Winners UNION ALL SELECT 1 AS idx, * FROM RelevantWinners and you'll have enough information available for a ...
J_H's user avatar
  • 25.5k
2 votes
Accepted

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

The Good Using subqueries instead of CTEs (which would impose an optimization boundary). The Bad You form a window in three different subqueries; it should only be needed in one. ...
Reinderien's user avatar
2 votes

Efficient Connection Pooling in ODBC-MSSQL with Rust (odbc-api)?

I am the author of the odbc-api Rust ODBC bindings. I would suggest returning a reference to an environment with a static lifetime from ...
Markus Klein's user avatar
1 vote

Filter filtered bike prices twice without repeating yourself

Thank you for the Fiddle, that's very helpful. primary key In BikeValuationList you neglected to tell the backend that BikeID is a Primary Key. Every relation should have a PK. foreign key ...
J_H's user avatar
  • 25.5k
1 vote

Need assistance in Optimizing the Recursive Query in Pyspark

Here is the Problem Statement as I heard it: A SQL Server stored procedure was running slowly, so it was converted to PySpark. The resulting PySpark function is running slowly. (Or, based on "...
J_H's user avatar
  • 25.5k
1 vote

Calculate the count of top performers in SQL

For illustration purposes I show that you don't necessarily need to use your windowing function, which generates one row for every row of the input; the intermediate table can be a ...
Reinderien's user avatar
1 vote

Calculate the count of top performers in SQL

The ROW_NUMBER in the CTE method is probably the most appropriate as you're also requiring the 0s to be shown in the results table. It has the advantage of a single ...
seanb's user avatar
  • 111
1 vote

Understanding how to properly create a stored procedure that only does INSERT from sourcetable to targettable with dynamic sql

documentation ...
J_H's user avatar
  • 25.5k
1 vote

Find All Recent Winners and Calculate an Encoding

Hullo, @J. Mini. I am deliberately responding to the followup over here, to keep the followup clean. We can move it later if warranted. Oh, and thank you for the fiddle! I find the original query ...
J_H's user avatar
  • 25.5k
1 vote

Write SQL Server table to Parquet file

Aside from the good points made by BCdotWEB, I think your code performance will already be quite good thanks to batch processing. One way improve the performance would be to interleave the reading of ...
ChrisWue's user avatar
  • 20.3k

Only top scored, non community-wiki answers of a minimum length are eligible