Viewing 15 posts - 1,156 through 1,170 (of 1,439 total)
-- Use a full outer join
WITH CTE(ID,Kind,Need,Score) AS (
SELECT COALESCE(s.ID,n.ID),
COALESCE(s.Kind,n.Kind),
n.Need,s.Score
FROM
( -- Test Data amount scored
select ID...
April 24, 2009 at 4:15 am
Try this
WITH CTE AS (
SELECT p1_id,p2_id,
ROW_NUMBER() OVER(PARTITION BY p1_id ORDER BY p2_id) AS rn1,
ROW_NUMBER() OVER(PARTITION BY...
April 23, 2009 at 2:09 am
See if this helps
SELECT USER,
SUM(CASE WHEN (NOT (STATUS= '90R')) AND (NOT (STATUS= '99I')) THEN 1 ELSE 0 END) AS Col1,
...
April 22, 2009 at 10:43 am
Maybe this?
DECLARE @BDate DATETIME
DECLARE @EDate DATETIME
SET @BDate = '20080101'
SET @EDate = '20080401'
SELECT u.UserName,
...
April 22, 2009 at 9:03 am
declare @mytable table (
[Group] varchar(30),
Node varchar(30),
Parent varchar(30))
insert into @mytable
SELECT 'AAA','POS2122941','POS2065860' UNION ALL
SELECT 'BBB','POS2081642','POS2081641' UNION ALL
SELECT 'BBB','POS2084810','POS2114958' UNION ALL
SELECT 'BBB','POS2092572','POS2081642' UNION ALL
SELECT 'BBB','POS2089937','POS2114958' UNION ALL
SELECT 'BBB','POS1008747','POS2081642' UNION ALL
SELECT 'BBB','POS2114958','POS2081641' UNION ALL
SELECT...
April 22, 2009 at 8:19 am
halifaxdal (4/22/2009)
Neither of the code are working. :hehe:2. to Mark: your code will return multiple root for single group, and some group has wrong parent
Can you post some sample...
April 22, 2009 at 8:04 am
select a.[Group],a.Parent as Root
from mytable a
where not exists (select * from mytable b where b.[Group]=a.[Group] and a.Parent=b.Node)
April 22, 2009 at 7:48 am
virgo (4/21/2009)
But can you please let me know how can i do the same with out using CTE feature of sql server , like may be...
April 21, 2009 at 1:49 pm
Anye Mercy (4/21/2009)
April 21, 2009 at 12:41 pm
Untested, but try this
with cte(ID,MsgCount,StartDate,EndDate) as (
select Table1ID,count(*),min(SomeDate),max(SomeDate)
from Table2
group by Table1ID)
update t1
set MsgCount=c.MsgCount, StartDate=c.StartDate, EndDate=c.EndDate
from Table1 t1
inner join cte c on t1.ID = c.ID
April 21, 2009 at 10:42 am
declare @id int
set @id=2;
with cte(id,lft,rgt) as (
select id,0,0
from user_registration_tbl
where id=@id
union all
select t.id,1-t.Node, t.Node
from user_registration_tbl t
inner join cte c on c.id = t.parentid)
select sum(lft) as lft,
...
April 21, 2009 at 7:23 am
Try this
declare @x xml
set @x='
...your XML here
'
SELECT
x.y.value('declare namespace s="http://schemas.microsoft.it.relationshipmanagement/2007/siebel/opportunity"; s:OpportunityId[1]', 'nvarchar(10)') AS OpportunityId,
x.y.value('declare namespace s="http://schemas.microsoft.it.relationshipmanagement/2007/siebel/opportunity"; s:Created[1]', 'nvarchar(10)') AS Created,
x.y.value('declare namespace s="http://schemas.microsoft.it.relationshipmanagement/2007/siebel/opportunity"; s:Modified[1]', 'nvarchar(10)') AS Modified,
x.y.value('declare namespace s="http://schemas.microsoft.it.relationshipmanagement/2007/siebel/opportunity"; s:AccountId[1]', 'nvarchar(10)') AS...
April 20, 2009 at 6:30 am
select city,
sum(case when code=251 then round(payment,2) else 0 end) as dectp,
sum(case when code=252 then round(payment,2) else...
April 18, 2009 at 11:08 am
SELECT Year,Zip,
SUM(CASE WHEN Groupp='A' THEN 1 ELSE 0 END) AS 'A',
SUM(CASE WHEN Groupp='B' THEN 1 ELSE 0 END) AS 'B'
FROM #Table1
GROUP BY Year,Zip
ORDER BY...
April 18, 2009 at 9:03 am
WITH CTE AS (
SELECT CUSTOMER_NO,
CURRENT_BALANCE,
ACTUAL_DATE,
ROW_NUMBER() OVER(PARTITION BY CUSTOMER_NO ORDER...
April 17, 2009 at 8:37 am
Viewing 15 posts - 1,156 through 1,170 (of 1,439 total)