Viewing 15 posts - 2,416 through 2,430 (of 4,085 total)
There are several ways that you can accomplish this. Probably the most straightforward is the following.
SELECT CAST(CAST(GETDATE() AS DATE) AS SMALLDATETIME)
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 31, 2016 at 3:45 pm
It's possible to do this with SSIS, but SSIS is complicated enough that I would not recommend trying this as your first SSIS project.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 31, 2016 at 12:41 pm
All results of a CASE expression must be of compatible data types and the data type with the highest precedence determines the final data type. You return a mix...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 30, 2016 at 1:15 pm
John Mitchell-245523 (8/26/2016)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 26, 2016 at 9:50 am
John Mitchell-245523 (8/26/2016)
SELECTTime_Started
,ROW_NUMBER() OVER (ORDER BY DATEPART(wk,Time_Started)) AS Week_No
FROM #tbl_data
John
Now try it with this data
INSERT INTO #tbl_data (
Time_Started
)
VALUES('2017-01-06 09:08:47.763'),
('2016-12-30 09:08:47.763'),
('2016-12-23 09:08:47.763'),
('2016-12-16 09:08:47.763');
This is why I asked about wrapping and...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 26, 2016 at 9:19 am
If by "slice", you mean filter, windowed functions are calculated after the WHERE clause, so the running total reflects any filters applied in the WHERE clause.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 26, 2016 at 8:15 am
sharonsql2013 (8/25/2016)
How can I rename 31 as week 1 , 32 as week2 , 33 as...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 25, 2016 at 4:07 pm
Lynn Pettis (8/25/2016)
Got to the following from a LinkedIn email. Not sure about a few of the answers.https://intellipaat.com/interview-question/sql-interview-questions/
I had to stop after number 12. There is no way...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 25, 2016 at 1:26 pm
JALLYKAMOZE (8/25/2016)
ProgramID INT, ID INT, ContractHeaderID INT, ContractStartTime TIME, ProgramStartTime TIME ,ContractDetailFirstDay INT ,ProgramFirstDay INT, DelaySeconds INT)
INSERT INTO DELAYSECONDS
VALUES (625, 625, 115278, '18:00:00', '18:00:00', 2, 2, 0),
...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 25, 2016 at 11:43 am
Luv SQL (8/25/2016)
I need to grab the sequence number from TableA not Table B.
The sequence number IS coming from TableA.
Part of the problem, is that you haven't been able to...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 25, 2016 at 11:16 am
I think what you are looking for is ROW_NUMBER(). Something like the following:
SELECT *, ROW_NUMBER() OVER(ORDER BY <pick some order here>) + ( SELECT MAX(sequence) FROM TableA)
FROM TableB
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 25, 2016 at 9:53 am
I haven't looked at the calculations, but replace your nested cursors with this. And why go to the trouble of specifying a name for the day of the week...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 24, 2016 at 3:51 pm
The Dixie Flatline (8/23/2016)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 23, 2016 at 3:53 pm
There are obvious problems with the "expected results" -- such as all of the times being the same and dates in the results that don't exist in the sample data...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 23, 2016 at 2:09 pm
Yes, use a different approach. Either shred the XML and make your adjustments on the shredded data or use .modify() to modify your XML.
Since you haven't provided sample data...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
August 23, 2016 at 11:22 am
Viewing 15 posts - 2,416 through 2,430 (of 4,085 total)