Viewing 15 posts - 946 through 960 (of 1,439 total)
Here's another way
WITH cteDupeName AS (
SELECT RowNum, Name, SomeValue,
COUNT(*) OVER(PARTITION BY Name) AS cn
FROM #TestData)
SELECT RowNum, Name, SomeValue
FROM cteDupeName
WHERE cn>1
ORDER BY RowNum;
January 26, 2010 at 6:27 am
Lynn Pettis (1/22/2010)
Perfect, Mark!
Thanks for the feedback!
January 22, 2010 at 1:51 pm
Try this
SELECT ...
FROM ...
ORDER BY MAX(QNTY) OVER(PARTITION BY PartGroup) DESC, QNTY DESC
January 22, 2010 at 1:40 pm
I think this gives you what you want, but I don't fully understand the requirements
SELECT n.Numbers,
COALESCE(STUFF((SELECT ','+p.Name AS "text()"
...
January 22, 2010 at 4:45 am
You can also replace the multiple 'OR's with an 'IN'
SELECT STK_STOCK_2.STKCODE2 AS [Stock Code], STK_STOCK_2.STK_SANALYSIS1 AS [Price Line 1], STK_STOCK_2.STK_SANALYSIS2 AS [Price Line 2],
...
January 22, 2010 at 3:08 am
WITH CTE AS (
SELECT [CustNo], [ContractNo], [RNo], [DateFrom], [Discount],
ROW_NUMBER() OVER(PARTITION BY [CustNo], [ContractNo], [RNo] ORDER BY [DateFrom] DESC) AS rn
...
January 21, 2010 at 6:08 am
This should do it
SELECT a.MapID,
a.SeriesID,
STUFF((SELECT ','+CAST(b.Year AS VARCHAR(10)) AS "text()"
...
January 21, 2010 at 2:32 am
Here's another guess
SELECT JOB.EMPLID,
JOB.FILE_NBR,
PER.NAME,
JOB.PAYGROUP,
...
January 20, 2010 at 9:54 am
Try this
UPDATE t1
SET multi_flag='Y'
FROM MyTable t1
WHERE EXISTS (SELECT * FROM MyTable t2
WHERE t2.exe_name=t1.exe_name
...
January 20, 2010 at 9:23 am
Untested, you may have issues with NULLs in your data
select t1.ID, t1.Tel1, t1.Tel2, t1.Tel3, t1.Tel4
from table1 t1
where exists (select * from table1 t2
...
January 16, 2010 at 3:55 am
andy 21711 (1/15/2010)
2) How can deadlocks appear in a database which doesn't use transactions?
Triggers can cause this
January 15, 2010 at 7:40 am
sqlislife (1/14/2010)
Thanks but I tried the dense_rank and it didn't work for me. Great piece of information learned though.
Presumably this?
select ID, name,
dense_rank() over (order by id asc) as Numbering,
count(*) over...
January 14, 2010 at 10:14 am
Sounds like a homework assignment, can you post what you have tried so far. Also what happens if a customer has two store locations with the same highest charges?
January 14, 2010 at 9:57 am
I've had to guess at what is a value 'Father' node, but gives the correct results with your data
declare @t table(Father int, Item int)
insert into @t(Father,Item)
select 49588, 71246 union all
select...
January 12, 2010 at 9:14 am
Untested...
WITH CTE AS (
SELECT A,B,C,V,
ROW_NUMBER() OVER(PARTITION BY A ORDER BY B,C DESC) AS rn
FROM ViewA)
SELECT A,C,V
FROM CTE
WHERE rn=1
January 8, 2010 at 8:16 am
Viewing 15 posts - 946 through 960 (of 1,439 total)