Viewing 15 posts - 961 through 975 (of 3,500 total)
Or use CROSS APPLY... but the above is probably easier.
SELECT p.Id
, p.Surname
, p.Bed
, p.OpDate
, patientData.SampleDate
, patientData.BP
, patientData.Temp
FROM Patient p
CROSS APPLY (SELECT TOP 1 ID, BP, Temp, SampleDate
FROM...
May 29, 2019 at 2:18 pm
What if you used ROWNUMBER() OVER (PARTITION BY StudentID) and then pivoted on that?
May 28, 2019 at 7:51 pm
Maybe read Jeff Moden's article on pivoting in T-SQL. Otherwise, could you post a CREATE TABLE script and an INSERT script to show some sample data?
Sounds like you need a...
May 28, 2019 at 4:06 pm
This might help:
https://stackoverflow.com/questions/3560173/store-arabic-in-sql-database
You have to change the collation for the various columns and use NVARCHAR() and NCHAR() because you need Unicode support.
May 21, 2019 at 8:22 pm
If you have a table for the times
CREATE TABLE HoursList (
HourNumber TINYINT PRIMARY KEY
, TimeSpan VARCHAR(10) NOT NULL
);
Then you insert values for each
INSERT INTO HoursList(0, '12 AM-1 AM'),(1,'1 AM -...
May 21, 2019 at 3:44 pm
SELECT y.EventDate
, y.EventHour
, COUNT(*) AS Freq
FROM
(SELECT x.EventDate,
DATEPART(hour,x.EventTime) AS EventHour
FROM
(SELECT '05/17/2019' AS EventDate, '00:51:39.0000' AS EventTime, 1 AS CallCount
UNION ALL
SELECT '05/17/2019', '06:54:34.0000', ...
May 20, 2019 at 6:27 pm
DATEDIFF with a CASE statement should do it.
May 14, 2019 at 4:46 pm
Why not just create a stored procedure to accept two parameters and then do two inserts? Sounds to me like you're making this waaaay more complicated than it should be.
May 9, 2019 at 10:56 pm
Any reason you couldn't take this and turn it into an INSERT statement into a table somewhere?
SELECT TOP 10
GETDATE() AS EventDate,
qs.total_worker_time/(qs.execution_count*60000000) as [Minutes Avg CPU Time], ...
May 9, 2019 at 9:29 pm
Can't help but wonder if the Top 5 change during the day/week. If so, it would make sense to include the execution date/time with the query name in the table....
May 9, 2019 at 8:47 pm
Maybe this? You don't need FILTER() if you are comparing a column value to a constant. You would need it if you were comparing a column to an aggregate.
May 6, 2019 at 8:25 pm
Something like (make a backup of the table or wrap the update in a transaction so you can roll it back...)
UPDATE EmployeeTable
SET EMailAddress = otherTable.EMail
WHERE EmployeeTable.FieldX = OtherTable.FieldY
Basically, you do...
May 3, 2019 at 7:25 pm
If you have only one value per month, then you can use LAG([Inventory],1) OVER (ORDER BY DateArchived) AS PrevValue
and then compare. Maybe easier to do it in T-SQL.
May 1, 2019 at 4:53 pm
Use a Calendar table maybe?
April 30, 2019 at 11:12 pm
Maybe this will help?
You could use multiple REPLACE functions
use tempdb;
go
CREATE TABLE TheReplacements(
Search_Value VARCHAR(15) PRIMARY KEY
, Replace_Value VARCHAR(15) NOT NULL
);
GO
INSERT INTO TheReplacements (Search_Value, Replace_Value)
VALUES ('Timothy','Tim'),('Kathleen','Kathy'),('Joseph','Joe'),('Michael','Mike');
CREATE TABLE People (
PersonID...
April 29, 2019 at 9:40 pm
Viewing 15 posts - 961 through 975 (of 3,500 total)