Viewing 15 posts - 2,986 through 3,000 (of 4,087 total)
laudena (7/14/2015)
SELECT month(DateField) as DteFld_Month, DAY(DateField) AS DteFld_Day, { fn HOUR(DateField) } AS DteFld_Hour, COUNT(MeasMyID) AS DupCount
FROM ...
July 17, 2015 at 12:31 pm
Please DO NOT CROSS POST.
You already have a thread here http://www.sqlservercentral.com/Forums/Topic1703612-3412-1.aspx. Creating a new post only serves to fragment the discussion.
Drew
July 17, 2015 at 8:29 am
You're using not equals when you should be using NOT EXISTS. So if the @StaffID = 101, the @SegmentID = 101, and the @SubjectID = 555 then using not...
July 17, 2015 at 8:25 am
As twin.devil already pointed out, if you use MERGE instead of a simple UPDATE, it will automatically raise an error if you try to update the same record twice. ...
July 17, 2015 at 7:14 am
A common practice is to use ROW_NUMBER() in a CTE to set the priority and then select the record in the main query where the row number = 1. ...
July 16, 2015 at 5:49 pm
It sounds like what you are looking for is the following.
SELECT name, cost, yr, mth, CAST(cost/AVG(cost) OVER(PARTITION BY name) AS DECIMAL(10,4))
FROM (
VALUES
('shory', 34346.00, 2014, 1)
,('qualig', 4637, 2015, 1)
,('qualig', 6044, 2014,...
July 16, 2015 at 3:23 pm
This is essentially an islands and gaps problem with the added wrinkle that the '@@@@@' records are counted in both the islands and the gaps. I used a cross...
July 15, 2015 at 2:56 pm
As a concrete example,
DECLARE @group_members TABLE (
user_id INT NOT NULL,
group_id INT NOT NULL,
role_id INT NULL,
from_date DATE DEFAULT SYSDATETIME(),
to_date DATE DEFAULT '9999-12-30'
)
INSERT @group_members(
user_id,
group_id
)
VALUES(1,...
July 15, 2015 at 11:22 am
Also, a 1-1 relationship means that not only can the person only have one group, but the group can only have one person. Groups, by definition, allow for multiple...
July 15, 2015 at 10:28 am
The standard way to handle a many-to-many relationship in an OLTP database is a bridge table, because that is the most efficient. Create a table for group memberships that holds...
July 15, 2015 at 10:20 am
This also works, but it doesn't perform as well as Kevin's even though it doesn't use a CTE.
SELECT DISTINCT widgetID
, FIRST_VALUE(funkCode) OVER(PARTITION BY widgetID ORDER BY...
July 13, 2015 at 3:54 pm
Welsh Corgi (7/13/2015)
I can copy and paste but not the whole line when I try and scroll.Could you please place the code outside of the CQL Code Tag?
Thanks.:-)
Also, when you...
July 13, 2015 at 11:14 am
ISNULL() requires an opening paren and the subquery also requires an opening paren. You are trying to conflate them. You also have the second argument of the ISNULL() in the...
July 13, 2015 at 9:40 am
sgmunson (7/10/2015)
July 10, 2015 at 12:05 pm
You're casting your strings as CHAR(), so it's padding your strings with spaces as necessary at the end. You want to cast it to VARCHAR().
Drew
July 9, 2015 at 7:18 am
Viewing 15 posts - 2,986 through 3,000 (of 4,087 total)