1,720 reputation
621
bio website
location Ukraine
age
visits member for 2 years, 9 months
seen 2 days ago

Jun
18
comment T-SQL Calculate average value for Duration Field
Strangely, thanks to you I've just discovered that DATEDIFF(SECOND, '00:00:00', Duration) is actually slower than your original suggestion, but replacing the '00:00:00' (a string) with a 0 (an integer) did make it faster (than your method). Don't know why we've got different conclusions. (If this matters, I didn't use a table in my tests, because I only wanted to test the expressions, so I assigned same expression to a variable in a loop and measured the time.)
Jun
18
awarded  Altruist
Jun
18
comment T-SQL Calculate average value for Duration Field
You could just get the difference in seconds between '00:00:00' and Duration instead of all the string manipulations.
Jun
18
revised Sequence is reusing
more formatting refinement
Jun
18
suggested suggested edit on Sequence is reusing
Jun
17
awarded  Investor
Jun
7
revised Why can't I use a CASE statement to see if a column exists and not SELECT from it?
grammar
Jun
6
awarded  Nice Answer
Jun
6
answered Why can't I use a CASE statement to see if a column exists and not SELECT from it?
Jun
6
comment Why can't I use a CASE statement to see if a column exists and not SELECT from it?
@MarkSinkinson: Names are checked after the syntax, but yes, SQL Server does that prior to actually running the batch.
Jun
5
comment Count where two or more columns in a row are over a certain value [basketball, double double, triple double]
TIL: PostgreSQL, like MySQL, permits referencing columns in GROUP BY by aliases or ordinal numbers.
May
30
comment MySQL stores 0.00 as 0?
Do you want it displayed as 0.00? Formatting should be done in the application.
May
23
comment How to Handle TimeZone Properly in SQL SERVER?
Such a toolkit would seem to be a great help for a developer. However, a scalar function is a black box to the query optimiser. It means that when I apply your function to a column, the configuration tables you are mentioning will be hit as many times as there are rows in the result set (assuming I use the function in the SELECT clause only). That doesn't seem a nice perspective in terms of performance. I haven't really tested your toolkit, though, so I can't say for sure, that's just a general concern based on what I know.
May
22
comment How can I minimize the risk of accidentally modifying the wrong database?
You mean that would somehow disable access to more than one server from a single SSMS instance? Or what have I missed?
May
15
comment How to find duration in a dataset
You are defining two identical subselects here. This is where using a CTE is helpful, because you can define your subselect as a CTE once and reference it multiple times (just like a view, except it is accessible in a single statement only). Here's one more example for you, this one illustrating how a CTE is re-used.
May
14
comment What is the strategy of query evaluation in DBMS when Limit is used in query?
I believe the point @ypercube is trying to make is that you are mixing groups, pages, likes in the same column, even though they are absolutely different entities. That is what makes no sense.
May
12
comment Get streak count and streak type from win-loss-tie data
Thank you for the clarification. I'm beginning to wish I hadn't upvoted your answer 20 min ago, because upvoting it now would have given me much greater satisfaction.
May
12
comment Get streak count and streak type from win-loss-tie data
Impressive! Is there a particular reason why your recursive part's WHERE is using EXISTS (... INTERSECT ...) instead of just Streaks.streak_type = CASE ...? I know the former method can be useful when you need to match NULLs on both sides as well as values but it's not as if the right part could produce any NULLs in this case, so...
May
8
comment Get streak count and streak type from win-loss-tie data
+1, I like the trick of using the descending order in LAG to later determine the last streak, very neat! By the way, since the OP only wants team IDs, you could replace FantasyTeams JOIN FantasyMatches with FantasyMatches CROSS APPLY (VALUES (home_fantasy_team_id), (away_fantasy_team_id)) and thus potentially improve performance.
Apr
16
revised Latitude and Longtitude Distance Calculation
more cleanup (typos, formatting)