Viewing 15 posts - 3,076 through 3,090 (of 5,504 total)
Ok, here's what I came up with:
Basically, I add a single row per database using UNION ALL and sort it as required.
The major downside (except for possible performance impacts due...
July 26, 2010 at 2:24 pm
I had a look at the bmp file you posted. That's not what I expected.
Please provide table structure (CREATE TABLE) and some INSERT INTO ... SELECT ... UNION ALL statements...
July 26, 2010 at 12:06 pm
Please post your expected result set based with reference to your sample data (either the first sample, the second or the data from the link you mentioned.
Regarding the c.u.r.s.o.r. *cough*:...
July 26, 2010 at 5:44 am
The secod section of the UNION operation has additional columns ([wrk_ha_calldetail].[id_ContactOutcome],[wrk_ha_calldetail].[id_CallResult]).
Either remove those columns or expand the first SELECT statement:
SELECT [wrk_ha_calldetail].[id_calllist], max(CreationDate) as CallDetailCreationDate,0 as [id_ContactOutcome], '' [id_CallResult]
FROM [wrk_ha_calldetail]
A few...
July 26, 2010 at 1:15 am
It seems like DynamicCrossTab is the best solution for this task.
Please have a look at the related article referenced in my signature.
If you'd like to see a coded version based...
July 23, 2010 at 11:59 am
Lynn Pettis (7/23/2010)
July 23, 2010 at 11:30 am
You need to have the same collation per column for each union statement.
Example
SELECT col1 collate Latin1_General_CS_AS, col2 collate Greek_CI_AS
FROM MyTable
WHERE condition
UNION ALL
SELECT col1 collate Latin1_General_CS_AS, col2 collate Greek_CI_AS
FROM MyTable2
WHERE condition
will...
July 22, 2010 at 3:07 pm
I'd probably use a CTE(common table expression)/subquery with ROW_NUMBER() and a self join to it. Then I would check for DATEDIFF(dd, cte1.enddate, cte2.EffDate)<30.
If you'd like to see a coded example...
July 22, 2010 at 3:02 pm
Are you sure both columns are datetime?
I think both are char/varchar, since it's unlikely to store the data the way you menitoned in a datetime column....
To be sure the solution...
July 22, 2010 at 2:57 pm
What part of your question remains unanswered based on my post on the other thread covering the very same issue??
July 22, 2010 at 2:01 pm
Joe Celko (7/21/2010)
SUM(<expression>)
OVER (PARTITION BY ..
...
July 22, 2010 at 1:53 pm
I'd query against a calendar table or an on-the-fly 12month subquery.
Based on that you'd get the AgtID expanded per month.
Something like
SELECT yr,mnth,ParentAgtID,AgtID
FROM
(
SELECT CAST('20100101' AS...
July 22, 2010 at 1:26 pm
Please re-read my previous post and provide data (including expected result) in a ready to use format.
July 22, 2010 at 12:19 pm
sharonmtowler (7/22/2010)
July 22, 2010 at 12:14 pm
I think the samples provided should help you to resolve your issues.
To add another counter, look what ROW_NUMBER actually does and try to modify it to your needs.
Regarding the PIVOT:...
July 22, 2010 at 12:10 pm
Viewing 15 posts - 3,076 through 3,090 (of 5,504 total)