Viewing 15 posts - 2,371 through 2,385 (of 4,086 total)
The WHERE clause is evaluated before the SELECT clause (which is where the ROW_NUMBER is defined), therefore the WHERE cannot reference the ROW_NUMBER in the same (sub)query where the ROW_NUMBER...
September 16, 2016 at 8:13 am
SQLBill (9/14/2016)
Conn1.temp01
Conn2.temp01
When using...
September 15, 2016 at 3:52 pm
The Dixie Flatline (9/15/2016)
select p.id, p.FirstName, p.LastName, p.dob, pf.pos,pf.Hobby, pf.Color, pf.SQLConference
from @Person p
join @Person_Favorites pf on p.ID = pf.ID
--where pf.SQLConference like 'SQL%'
--where color...
September 15, 2016 at 3:23 pm
Michael L John (9/15/2016)
WHERE
CONVERT(varchar(20), H.TransactionDate, 101) >= @StartDate
AND CONVERT(varchar(20), H.TransactionDate, 101) <= @EndDate
If...
September 15, 2016 at 1:29 pm
Both Alan.B and Gazareth started with the summarized data. Here is how you would do it starting with the raw data.
DECLARE @table TABLE (stateName varchar(20), Amount int);
INSERT @table
VALUES
('Alabama',200),
('Alabama',200),
('Alabama',200),
('Alabama',200),
('Alabama',200),
('Arizona',2000),
('Arizona',2000),
('Arkansas',2000),
('Arkansas',2000),
('Arkansas',1000)
;
SELECT...
September 15, 2016 at 1:20 pm
John Mitchell-245523 (9/15/2016)
September 15, 2016 at 8:53 am
A TOP(n) requires an order, which you haven't specified, but there is only one field that will give your specified results, so I have used that field.
SELECT InvRef, Amount, Date,...
September 15, 2016 at 8:49 am
j-1064772 (9/15/2016)
tripleAxe (9/15/2016)
September 15, 2016 at 8:16 am
Clean up your data before submitting it to your function.
DECLARE @input VARCHAR(250) = 'abc,def,ghi,123,jkl,345,678,mno,901,234,567,pqr'
WHILE PATINDEX('%[0-9],[0-9]%', @input) > 0
SET @input = STUFF(@input, PATINDEX('%[0-9],[0-9]%', @input) + 1, 1, '')
You should also change...
September 14, 2016 at 1:12 pm
Lynn Pettis (9/13/2016)
drew.allen (9/13/2016)
I think someone is in way over their head. Maybe we should just tell him to find another line of work.Drew
Who?
This is his most recent question:...
September 14, 2016 at 8:46 am
Jason A. Long (9/14/2016)
Jeff Moden (9/14/2016)
September 14, 2016 at 8:06 am
I think someone is in way over their head. Maybe we should just tell him to find another line of work.
Drew
September 13, 2016 at 3:58 pm
Dude! This goes well beyond the scope of a free forum.
Drew
September 13, 2016 at 3:54 pm
CELKO (9/13/2016)
We do not like to write with bit flags in RDBMS and SQL; that was assembly language programming.
This is T-SQL, not some idealized theoretical version of SQL. T-SQL...
September 13, 2016 at 3:25 pm
This solution requires 2012, since it uses LEAD, FIRST_VALUE, and LAST_VALUE.
WITH holding_ends AS (
SELECT *,
CASE
WHEN h.Amount = 0 THEN h.EffectiveDate
WHEN h.EffectiveDate = FIRST_VALUE(h.EffectiveDate) OVER(PARTITION BY h.Holder ORDER BY h.EffectiveDate ROWS...
September 13, 2016 at 3:09 pm
Viewing 15 posts - 2,371 through 2,385 (of 4,086 total)