Skip to content

Combining several similar queries

How can I combine these three queries into one? SELECT COUNT(*) FROM Users WHERE (SELECT COUNT(*) FROM Posts WHERE Posts.OwnerUserId = Users.Id) < 10; SELECT COUNT(*) FROM Users WHERE (SELECT …

Oracle SQL if statement?

how would it be possible to check if a certain value in salesman_id is null, and if it is, assign it to something else (in this case, 0)? here’s what i’ve wrote up so far: SELECT O.SALESMAN_ID, SUM(OI….

STUFF function truncated result

I am trying to generate dynamic sql by querying a table and using the STUFF function and returning the results into a variable (DECLARE @dynamic_query NVARCHAR(max)). My problem is that the results returned by the STUFF function are truncated/incomplete. The content of @dynamic_query will be cut short. I can&…

How to force Postgres to calculate with numeric precision

I have a .net core application using dapper with Postgresql. Windows, PostgreSQL 12.0, compiled by Visual C++ build 1914, 64-bit When i do simple calculation in the select-statement, then i get different results if i do not provide fractions: 1258 1208 What’s the reason and what’s the best way to …