New answers tagged

1

Discarded sums You calculate these sums: sum(case when s.type = 'in' then s.quantity else 0 end) as 'in', sum(case when s.type = 'out' then s.quantity else 0 end) as 'out' but then reduce them to a 0/1 here: if(coalesce(x.in - x.out, 0) = 0, 0, 1) as quantity, This means that a sum is not appropriate at all. This should be refactored to an if exists, ...


2

The query title is Questions answered by more than 3 50k users But that doesn't describe what the query actually does. The query selects questions with three answers given by three distinct top n rated users. They happen to have more than 50k rep on that site, but that's a mere coincidence. That can also be done by this query, containing only 1 subquery to ...


1

I discovered what I think is a flaw - in Flush() I call simply Flush() on the underlying stream, however I think this needs to be Flush(true) to ensure that all the changes are written before the log file is reset. I made the same change in Log.cs. This means changing the type of BaseStream to FileStream, as Flush(true) is specific to FileStream. The ...


1

Based on the nearly the same idea from Celko's book I came up with another version without arrays&rows but still using common table expression. WITH RECURSIVE DocumentGraph AS ( SELECT DISTINCT document1_id document2_id, 0 depth, '/2856' path FROM DocumentCyclicDependency WHERE document1_id = 2856 UNION ...


3

I am not well qualified to answer this, as I know nothing of PostgreSQL or the RECURSIVE extension you are using, so unfortunately I cannot very well comment on your solution. However perhaps it can be tackled with (relatively!) standard SQL. Let's define a temporary table CREATE TABLE #Temp ( id int, status int ) A status of 1 will indicate the node is ...


0

Just a few remarks. You constantly use $_POST across your code eg $_POST['username'] Example: if (empty($_POST["username"])) { $errors[] = "Fill in username to sign up"; } You should collect the form fields to variables, sanitize them etc once, then reuse the variables in the rest of the code. What I mean is something like this: <?php // init ...


Top 50 recent answers are included