Quantcast
Channel: User Gordon Linoff - Stack Overflow
Browsing all 45 articles
Browse latest View live

Comment by Gordon Linoff on the number is rounded in postgresql

Your code works fine in the database (dbfiddle.uk/…). The problem must be how you are displaying the number.

View Article



Comment by Gordon Linoff on How to get running total of unique IDs

Edit your question and show sample data and desired results. It is not clear how you want the running total to be.

View Article

Comment by Gordon Linoff on Count the number of times an id appears across...

@tommygibbons …“v” is a table aliasa

View Article

Comment by Gordon Linoff on How to get everything before the last occurrence...

@ifediokonkwo … reversing the entire string is relatively expensive compared to this approach. Also, reverse() is an extension provided by MySQL.

View Article

Comment by Gordon Linoff on Multiple strings in LIKE condition - Presto SQL

@Stevoisiak … I would expect it to be a wee bit faster. There is only one function call versus a call for each pattern. However, it is worth testing on your database.

View Article


Comment by Gordon Linoff on combinations in sql without repetitions

That operator is a comparison. The SQL statement is doing a self-join on Teams, keeping only rows where s1.sk is less than s2.sk.

View Article

Comment by Gordon Linoff on Convert rows to columns by same column value in...

@ilia … You could aggregate by the first letter (and id)

View Article

Comment by Gordon Linoff on Conditional RowNumber

It does the same thing as it does elsewhere. The purpose is to separate the NULL values.

View Article


Comment by Gordon Linoff on conditional join with input value in postgreslq...

Phish… that depends on the database. However a full outer join keeps all rows from bothctables

View Article


Comment by Gordon Linoff on Can anyone please explain this solution of hacker...

The subquery aliases it to b2.

View Article

Comment by Gordon Linoff on Postgresql: Join another column on the least...

The question is tagged Postgres.

View Article

Comment by Gordon Linoff on Create date from integers in separate fields in...

@akshay… because you need the month and day of month.

View Article

Comment by Gordon Linoff on SQL Server Dynamic Order By Performance Issue

It should be less than running the query

View Article


Comment by Gordon Linoff on Find text of a column in other column with T-SQL

@roland… your comparison doesn’t have a.x.

View Article

Comment by Gordon Linoff on SQL Server: Cannot Insert Default Column Value

@matthaisburger … This answer is specific to SQL Server

View Article


Answer by Gordon Linoff for Is there a fundamental difference between...

They are very different, even in your case.The INNER JOIN will return duplicates, if id is duplicated in either table. INTERSECT removes duplicates. The INNER JOIN will never return NULL, but INTERSECT...

View Article

Answer by Gordon Linoff for RANK(), DENSE_RANK(), and COUNT() in SQL Server

If you want the ranking, perhaps rank() will do want you want:SELECT TOP 100 T.PGM AS Program, COUNT(*) AS ProgramCount, RANK() OVER (Order BY COUNT(*) DESC) as rankingFROM StudentPrograms TWHERE T.PGM...

View Article


Answer by Gordon Linoff for Efficient algorithm to find the n-th digit in the...

Well, you have a series of sequences each increasing by a single number.If you have "x" of them, then the sequences up to that point occupy x * (x + 1) / 2 character positions. Or, another way of...

View Article

Answer by Gordon Linoff for Redshift ROUND function doesn't round in some cases?

If your issues is all those 9999s, then the issue is floating point representation. Convert to a decimal to get fixed-point precision:select round(cast(176 as float)/cast(492 as float), 4)::decimal(10,...

View Article

Answer by Gordon Linoff for Cumulative Sum When rows have the same value sql...

You need a row windowing clause or a stable sort. Try this: SUM(SubTotal) OVER (partition by YEAR(OrderDate) ORDER BY OrderDate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS RunningTotalOr, if...

View Article
Browsing all 45 articles
Browse latest View live




Latest Images