Viewing 15 posts - 616 through 630 (of 1,439 total)
Try this
DECLARE @DetailTable TABLE(Store INT, PhoneNr VARCHAR(30))
INSERT INTO @DetailTable(Store, PhoneNr)
SELECT 4711, '49911-1111111' UNION ALL
SELECT 4711, '49911-1111112' UNION ALL
SELECT 4711, '49911-1111113';
WITH CTE AS (
SELECT Store, PhoneNr,
...
March 29, 2012 at 1:42 am
Jeff Moden (3/27/2012)
Eugene Elutin (3/27/2012)
...
Try adding this into the original sample data
SELECT 'Jun 1 2011 12:00AM','1','10','20' UNION ALL
The results of the two queries are different.
My query will only ...
March 28, 2012 at 1:44 am
Eugene Elutin (3/27/2012)
Lets create some more test data (around 1.3 millions records)
declare...
March 27, 2012 at 7:27 am
philippe-546556 (3/27/2012)
Brilliant. I don't understand it yet, but still brilliant. Many thanks for your help!Philippe
The "Group Islands of Contiguous Dates" article I referenced explains how this works.
March 27, 2012 at 4:58 am
See the link here
http://www.sqlservercentral.com/articles/T-SQL/71550/
WITH CTE AS (
SELECT [Month],[ItemID],[count A],[count B],
ROW_NUMBER() OVER(PARTITION BY [ItemID] ORDER BY [Month]) -
...
March 27, 2012 at 4:41 am
Use OUTER APPLY
SELECT x.name.value('@name[1]', 'VARCHAR(10)') AS name
,y.name.value('@ID[1]', 'INT') as ID
,y.name.value('@color[1]', 'VARCHAR(10)') as Color1
,z.name.value('@color[1]', 'VARCHAR(10)') as Color2
FROM @data.nodes('/Automobile/Car') x(name)
OUTER APPLY x.name.nodes('Properties') y(name)
OUTER APPLY x.name.nodes('PropertiesGroup') z(name)
March 26, 2012 at 8:24 am
GilaMonster (3/26/2012)
March 26, 2012 at 7:37 am
Just a GROUP BY should do it
SELECT [Model Number], MIN(Price) AS Price
FROM myTable
GROUP BY [Model Number]
March 26, 2012 at 4:17 am
SELECT u.C8,
(SELECT g.groupname+';' AS "text()"
FROM group_cache g
WHERE...
March 21, 2012 at 8:39 am
This gives you just the active and idle time in minutes. You'll have to format this to give HH:MM:SS.
WITH AllTimes AS (
SELECT MachineID, TimeStart AS tm
FROM @TempSource
UNION
...
March 21, 2012 at 7:37 am
See if this helps
DECLARE @phoneDetail TABLE(CustomerID INT,Row INT,PhoneType VARCHAR(20),
...
March 20, 2012 at 3:52 am
Still not clear what you're asking. If your XML is in a table, you can use CROSS APPLY to get the values.
SELECT x.r.value('@date_changed','DATETIME') AS date_changed,
...
March 19, 2012 at 10:21 am
This will give the XML as columns. You'll need to give more information about how to calculate the other columns you're after.
DECLARE @x XML
SET @x='<Rates>
<Rate date_changed="Nov 10 2011...
March 19, 2012 at 8:28 am
Using recursive CTEs
WITH Recur AS (
SELECT MessageThread,MessageContent,MessageID,MessageDate
FROM ThreadMessage
WHERE MessageParent=0
UNION ALL
SELECT r.MessageThread,r.MessageContent,m.MessageID,m.MessageDate
FROM ThreadMessage m
INNER JOIN Recur r ON r.MessageID=m.MessageParent
)
SELECT MessageThread AS ThreadID,
...
March 19, 2012 at 3:10 am
You can use recursive CTEs for this
SET NOCOUNT ON
DECLARE @fctTable TABLE(Id INT,refTableId INT)
INSERT INTO @fctTable(Id,refTableId)
SELECT 1 , 2 UNION ALL
SELECT 2 , 7 UNION ALL
SELECT 3 , 4 UNION ALL
SELECT...
March 16, 2012 at 5:50 am
Viewing 15 posts - 616 through 630 (of 1,439 total)