Viewing 15 posts - 3,271 through 3,285 (of 4,085 total)
Chris Harshman (3/23/2012)
interesting problem, I think windowed functions work well here:
I've found that the windowed aggregates do a LOT of reads. You might be better off using a NOT...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 23, 2012 at 9:20 am
Actually, the correct answer (assuming that your date fields are actual date fields) is that it's IMPOSSIBLE. Your expected output violates first normal form, because some of the rows...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 22, 2012 at 9:32 am
Assuming that there is some date changed associated with each of the changes, use that to determine which change is more recent.
Option 2 is to update the source of the...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 21, 2012 at 3:15 pm
Your criteria for which rows to update in your merge is incomplete. Since you forgot to include the DDL for your tables, sample data, expected results, and your current...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 21, 2012 at 2:50 pm
Snargables (3/21/2012)
To be honest based on the above info i suppose my only issue w/ dynamic sql now is its readbility. It's just plain ugly.
A lot of that may depend...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 21, 2012 at 1:42 pm
Someone else recently posted the exact same question, so this looks like a homework assignment. I suggest you try it on your own first.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 21, 2012 at 8:47 am
captcooldaddy (3/20/2012)
also only the records who need to be update...removed left join
UPDATE t1 SET field1 = t2.field1
FROM Table1 t1 JOIN Table2 t2 ON
t2.id1 = t1.id1
AND t2.id2 =...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 21, 2012 at 6:45 am
SGT_squeequal (3/20/2012)
Like other people suggest i would approach this using a pivot table, why does you boss object to a using pivot?
You do realize that that comment was made THREE...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 21, 2012 at 6:40 am
captcooldaddy (3/20/2012)
UPDATE t1 SET field1 = t2.field1
FROM Table1 t1 JOIN Table2 t2 ON
t2.id1 = t1.id1
AND t2.id2 = t1.id2
where...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 20, 2012 at 2:48 pm
Sean Lange (3/20/2012)
Drew I am curious if you have seen performance improvements with this multiple queries over the way I posted above. Or is it just personal preference?
Just to be...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 20, 2012 at 10:56 am
I don't know MySQL either, but here is an approach using a Tally table. (I may have the syntax for REGEX wrong.)
SELECT Min(n) AS n
FROM YourTable
INNER JOIN Tally
ON Len(YourTable.YourString)...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 20, 2012 at 10:26 am
It's easy to calculate the beginning of the month using the following function.
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)
You can then use that in your CASE expression or WHERE clause as appropriate.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 20, 2012 at 10:11 am
With only one parameter, the dynamic SQL option is probably overkill. Here is another option that I have seen, which is fine with only one parameter.
IF @StaffID IS NULL...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 20, 2012 at 9:25 am
The error is coming from your Caché database, so you'll probably get a better answer from a Caché forum, but it looks like Caché doesn't support the DATE datatype.
Another...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 20, 2012 at 8:43 am
itskanchanhere (3/15/2012)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 15, 2012 at 8:33 am
Viewing 15 posts - 3,271 through 3,285 (of 4,085 total)