Viewing 15 posts - 106 through 120 (of 921 total)
SELECT CONVERT(char(12),dt,113)
FROM
(SELECT MIN(Dt) dt
FROM Dates
UNION ALL
SELECT TOP 4 dt
FROM
(SELECT MAX(Dt) dt
FROM Dates
WHERE Dt <
(SELECT MAX(Dt)
FROM Dates)
GROUP BY CONVERT(char(6),Dt,112)) m
ORDER BY dt DESC
UNION ALL
SELECT MAX(Dt)
FROM Dates)...
March 8, 2004 at 2:16 pm
SELECT i.FEmpID, i.FTime FTimeIn, o.FTime FTimeOut, CONVERT(char(5),o.FTime - i.FTime,14) Hours
FROM Punches i LEFT JOIN Punches o ON i.FEmpID = o.FEmpID AND o.FType = 'OUT' AND o.Ftime =
(SELECT MIN(FTime)
FROM Punches
WHERE...
March 8, 2004 at 1:29 pm
I'll come right out and say that I think the quality of answers declined markedly since the contests started. I essentially stopped posting once the quantity over quality motivation became...
March 4, 2004 at 1:49 pm
You're welcome. Notice how much easier it is to find a solution once you provide some hard information.
Actually, you may want this...
March 2, 2004 at 12:03 pm
SELECT e.Event_Number, e.DtTm_Rcd_Added, ep.First_Name + ' ' + ep.Last_Name PatientName,
ev.First_Name + ' ' + ev.Last_Name Vistor, v.Pi_Type_Code, g.System_Table_Name
FROM Event e
JOIN Person_Involved p ON e.Event_Id = p.Event_Id AND p.Pi_Type_Code = 238
JOIN...
March 2, 2004 at 11:32 am
SELECT e.Event_Number, e.DtTm_Rcd_Added, ep.First_Name + ' ' + ep.Last_Name PatientName,
ev.First_Name + ' ' + ev.Last_Name Vistor, v.Pi_Type_Code, g.System_Table_Name
FROM Event e
JOIN Person_Involved p ON e.Event_Id = p.Event_Id AND p.Pi_Type_Code = 238
JOIN...
March 2, 2004 at 6:56 am
Are you looking for something like this?
SELECT d.DeptName, e.EmpName, e.Salary
FROM Employees e JOIN Departments d ON e.DeptCode = d.DeptCode
JOIN
(SELECT DeptCode, MAX(Salary) Salary
FROM Employees
GROUP BY DeptCode) x ON e.DeptCode = x.DeptCode...
February 24, 2004 at 6:02 am
It doesn't work (without tweaking; notice I chopped the first piece off) unless you have four or fewer pieces to extract. PARSENAME() is also limited to 128 characters per piece...
February 24, 2004 at 4:50 am
Without knowing what columns belong to which tables, I cannot confidently write your query, but perhaps this will help you understand how to do this:
USE Northwind
GO
SELECT r.CustomerID, r.OrderID, SUM(e.UnitPrice *...
February 23, 2004 at 1:24 pm
No need for a function. If the column is longer than 30 characters, then adjust the length of the varbinary type being casted.
SELECT CASE WHEN CAST(Col AS varbinary)=CAST(UPPER(Col) AS varbinary)...
February 23, 2004 at 12:42 pm
Assuming there may be periods but no tildes or carets in the data:
SELECT Account, Address, LEFT(Address,CHARINDEX(';',Address)-1) Address1,
REPLACE(REPLACE(PARSENAME(REPLACE(REPLACE(STUFF(Address,1,CHARINDEX(';',address),''),'.','~'),';','^.^'),4),'^',''),'~','.') Address2,
REPLACE(REPLACE(PARSENAME(REPLACE(REPLACE(STUFF(Address,1,CHARINDEX(';',Address),''),'.','~'),';','^.^'),3),'^',''),'~','.') Address3,
REPLACE(REPLACE(PARSENAME(REPLACE(REPLACE(STUFF(Address,1,CHARINDEX(';',Address),''),'.','~'),';','^.^'),2),'^',''),'~','.') Address4,
REPLACE(REPLACE(PARSENAME(REPLACE(REPLACE(STUFF(Address,1,CHARINDEX(';',Address),''),'.','~'),';','^.^'),1),'^',''),'~','.') Address5
FROM AddrSrc
February 23, 2004 at 12:24 pm
USE Northwind
GO
CREATE TABLE #Basket(
CustomerID nchar(5),
ProductID int,
Qty smallint)
INSERT #Basket
SELECT 'SAVEA',1,4
UNION ALL SELECT 'SAVEA',2,2
UNION ALL SELECT 'SAVEA',13,1
SELECT ProductId,
(SELECT TOP 1 UnitPrice
FROM [Order Details] d JOIN Orders o ON d.OrderID = o.OrderID
WHERE...
February 23, 2004 at 11:45 am
How about using an inner join? That should be simpler and more efficient.
SELECT t1.*
FROM Table1 t1 JOIN Table2 t2 ON t1.Id1 = t2.Id1 AND t1.Id2 = t2.Id2
February 13, 2004 at 2:45 pm
SELECT CAST(LEFT(GETDATE()-DAY(GETDATE()),11) AS datetime) LastDayLastMo,
CAST(LEFT(GETDATE()-DAY(GETDATE())+1,11) AS datetime) FirstDayThisMo,
CAST(LEFT(DATEADD(m,1,GETDATE()-DAY(GETDATE())+1),11) AS datetime) FirstDayNextMo
February 11, 2004 at 6:57 pm
Viewing 15 posts - 106 through 120 (of 921 total)