Reputation
4,355
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
1 14 34
Newest
 Suffrage
Impact
~166k people reached

Jan
20
comment How to clean up tables that don't belong into mysql/mysql database?
@donquixote: The mysql Database Tables - MariaDB Knowledge Base (no idea if that list is exhaustive, though – looks like it should be but I'm not sure)
Jan
20
revised How do I write this query?
edited tags
Jan
20
revised How do I write this query?
minor corrections
Jan
20
comment How do I write this query?
You could probably reduce case when @grp_lag != grp_id then @rownum:=1 else @rownum:=@rownum+1 end to @rownum := @rownum * (@grp_lag = grp_id) + 1.
Jan
20
comment Left Join Not returning rows when date is in range of longer than 1 day
Neither A nor B matches any of the table names or aliases used in the posted query, so please either modify your query or start using the names that it's referencing. However, a picture is worth a thousand words, you know, so an example illustrating your problem would really be helpful (in your question instead of the comments, please). Just add a sample of each table, the result you actually get for those samples, and the result you want instead.
Jan
20
revised Query with sp_executesql returns nothing while query without it returns the result
added 5 characters in body; edited tags; edited title
Jan
20
comment Left Join Not returning rows when date is in range of longer than 1 day
Do you mean that, when it's 2 days or more, the query returns rows but there are no NULLs among them? Do you mean you want your output to have each date in the BETWEEN range, whereas it actually has only dates that are present in the source table(s)?
Jan
17
reviewed Close RIGHT() works in a SELECT but not in an UPDATE?
Jan
14
reviewed Close How to set roles and users with correct permissions on Postgres?
Jan
14
comment Find the winner of each stage
"A colleague referred me to sqlfiddle.com to help me figure this out…" – you mean you don't have access to an instance of SQL Server to be able to work out a solution (whether at home or at work/school)? Does that mean that you won't be able to test whatever solution you will be offered here?
Jan
14
reviewed Close Remove parent and child rows if child or parent fits criteria
Jan
14
reviewed Reviewed How to transpose rows to column in datatabse
Jan
14
reviewed Leave Closed Select Max in stored procedure
Jan
14
comment Sql getting debit, credit and balance issue
@GDD: Well, yes, absolutely, running totals/balances are typically calculated following the order of events as they were happening. The desired output in this case, however, clearly indicates a different order. It's probably easier to see starting with InvoiceID 76: +1000 (Balance=1000), -500 (Balance=1000-500=500), +500 (this is a new invoice now but Balance=1000, meaning it includes the previous balance of 500). I'm with you in that it's very unusual and I'm ready to assume that the OP may be confused, but still, that's the sorting specified so far.
Jan
14
comment Sql getting debit, credit and balance issue
Based on the desired output posted, the OP doesn't just want to change the sorting for the output – they want the cumulative balance to follow the same sorting as well.
Jan
14
comment Guid vs INT - Which is better as a primary key?
All right, but that doesn't really explain why the OP should use both int and guid, as you are suggesting in your answer. And besides, I wasn't talking about explaining your suggestion just to me – my point was that you might want to update your answer. By the way, are you aware that another answerer has already suggested the same (more or less) as you?
Jan
14
reviewed Close SQL Server Backups on DataDomain
Jan
14
reviewed Reviewed Guid vs INT - Which is better as a primary key?
Jan
14
comment Guid vs INT - Which is better as a primary key?
Explaining your reasoning behind this suggestion wouldn't hurt anyone, I'm sure.
Jan
13
comment MySQL: Is there a way to transform string formats?
If it's about string transformation, then your question probably boils down to How to do a regular expression replace in MySQL?. Although about databases in general, I think it's more a programming question and would probably fit better on Stack Overflow. Therefore, I'm voting to migrate it.