Viewing 15 posts - 676 through 690 (of 3,543 total)
Stefan Krzywicki (6/6/2014)
June 6, 2014 at 7:44 am
WITH cte (locationid,flag,RID) AS (
SELECT locationid,flag,ROW_NUMBER() OVER (
PARTITION BY locationid
ORDER BY ISNULL(createddate,modifieddate) DESC)
FROM #templocationhistory)
UPDATE l
SET l.maintainancefalg = ISNULL(CAST(cte.flag as varchar(1)),'')
FROM #templocation l
LEFT JOIN cte ON cte.locationid = l.locationid AND...
June 6, 2014 at 7:09 am
Michael Meierruth (6/3/2014)
zafarthesultan (6/2/2014)
June 3, 2014 at 2:17 am
The only way I can think of to process data with split row delimiter is to BULK load the data as CLOB using OPENROWSET and then parsing the data.
Without knowing...
June 2, 2014 at 6:12 am
If you want your results based on insert order and you add IDENTITY column you would end up with something like this
CREATE TABLE #sampledata
(
RowID int IDENTITY(1,1),
userId int,
BaseYear int,
TotalSales float
)
INSERT...
May 30, 2014 at 9:21 am
Sean Lange (5/30/2014)
I felt it important to state though in case others wander in here someday. 😀
And quite right too! 🙂
May 30, 2014 at 9:04 am
Luis Cazares (5/30/2014)
May 30, 2014 at 9:01 am
Sean Lange (5/30/2014)
David Burrows (5/30/2014)[hrthe table is a heap and therefore has no order.
Tables have no order if it is a heap or not. A clustered index does not provide...
May 30, 2014 at 9:00 am
Your results indicate that you want first and last by insert order. the table is a heap and therefore has no order.
You will need to add an IDENTITY column...
May 30, 2014 at 8:55 am
Because you are creating dynamic sql (why in this case with a fixed name?) you need to add extra quotes to get quotes in the query, like this
SET @temp_xml1 =...
May 30, 2014 at 6:23 am
Tallboy (5/28/2014)
May 29, 2014 at 1:59 am
SELECTt1.StaffID,
SUM(t2.ALHours) AS [ALHours],
SUM(t3.SLHours) AS [SLHours]
FROMtable1 t1
LEFT JOIN table2 t2
ON t2.StaffID = t1.StaffID
AND t2.WeekendingDate = t1.WeekendingDate
LEFT JOIN table3 t2
ON t3.StaffID = t1.StaffID
AND t3.WeekendingDate = t1.WeekendingDate
WHEREt1.StaffID = @StaffID
ANDt1.WeekendingDate...
May 28, 2014 at 6:40 am
Tallboy (5/27/2014)
customerID , Max(4WeekEndDate), Sum(WorkedHours)
123456 , 30/1/14 ...
May 28, 2014 at 1:56 am
;WITH cte (CustomerID,WeekEndingDate,WorkedHours,WeekNo) AS (
SELECT CustomerID,WeekEndingDate,WorkedHours,CEILING(ROW_NUMBER() OVER (PARTITION BY CustomerID ORDER BY WeekEndingDate) / 4.0)
FROM )
SELECT CustomerID,MAX(WeekEndingDate),SUM(WorkedHours)
FROM cte
GROUP BY CustomerID,WeekNo
ORDER BY CustomerID ASC,2 ASC
May 27, 2014 at 10:21 am
Also if your data contains duplicate invoice dates as shown in the result set in your first post then you will need to use DENSE_RANK not ROW_NUMBER.
Plus your two requirements...
May 27, 2014 at 10:00 am
Viewing 15 posts - 676 through 690 (of 3,543 total)