Viewing 15 posts - 5,536 through 5,550 (of 10,143 total)
Koen Verbeeck (9/28/2012)
Grant Fritchey (9/27/2012)
THREADIZENS!Who is going to make it to any of the SQL in the City events coming up in the next week+?
If you do one in Brussels...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 28, 2012 at 2:35 am
Here's a fourth method:
-- solution
;WITH ParentsOnly AS (
SELECT ComputerName, ChildRows = COUNT(*)
FROM #MyTable
GROUP BY ComputerName
)
SELECT a.*, b.*, x.*
FROM ParentsOnly a
INNER JOIN ParentsOnly b ON b.ChildRows = a.ChildRows AND b.ComputerName...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 28, 2012 at 2:31 am
Shadab Shah (9/28/2012)
I had written the lines of code as
Cast(SUM(A*B) / SUM(C) AS DECIMAL(30,5)) and
Cast(SUM(A*B) AS DECIMAL(30,5))/Cast(SUM(C) AS DECIMAL(30,5))
Conceptually both should return the same result , which is...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 28, 2012 at 2:05 am
harri.reddy (9/27/2012)
hii want to insert 1000 rows in a table without any loop.
how can i do it?
In what format are the 1000 rows?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 28, 2012 at 2:03 am
Barry Couch (9/27/2012)
CASE @SortColumn WHEN 'StreetName' THEN Maintainer + ', ' + StreetName END ASC,but how could I do something like sorting by Maintainer ASC and StreetName DESC?
You will need...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 28, 2012 at 1:56 am
vinay.varaala (9/27/2012)
thanks a lot ..can I subtract todaysales- weeksale as other column
many thanks
Yes of course. To keep the query nice, either call it as a CTE or use it as...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 8:39 am
vivekkumar341 (9/27/2012)
Try this.DECLARE
@ta VARCHAR(MAX) = '107.3'
SELECT SUBSTRING(@ta,0,CHARINDEX('.',@ta,0)) + SUBSTRING(@ta,CHARINDEX('.',@ta,0) + 1,LEN(@ta))
Why? How is it relevant to this thread? The OP isn't even around any more - he's a tuna fisherman...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 8:00 am
Eugene Elutin (9/27/2012)
ChrisM@Work (9/27/2012)
Eugene Elutin (9/27/2012)
I have read a spec... 🙂...
Obviously not this OP's spec! The input value is supposedly DECIMAL(5, 4), however this appears to clash with the quoted...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 7:38 am
komal145 (9/26/2012)
UPDATE TableC
SET step_desc= Tableb.StepDescription
FROM #MAX_STEPMAX_STEP WITH (NOLOCK)
JOIN TablebB WITH (NOLOCK) ON MAX_STEP.LoanNumber = b.LoanNumber
and MAx_step.Step=b.step
...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 7:29 am
This is a little more tricky but reads the tables only once.
SELECT
SumTodaySales = SUM(CASE WHEN CAST(tr.Reading_Date AS DATE) = dates.Today THEN tr.Sales ELSE 0 END),
SumLastweekSales = SUM(CASE...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 6:31 am
Eugene Elutin (9/27/2012)
I have read a spec... 🙂...
Obviously not this OP's spec! The input value is supposedly DECIMAL(5, 4), however this appears to clash with the quoted numbers in the...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 6:27 am
Here's the simplest way. Note that performance will suck because you're doing all of your table reads twice:
;WITH SalesToday AS (
select
SumSales = SUM(tr.Sales),
t1.Tank
from Transactions as tr...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 6:15 am
diptidjadhav (9/27/2012)
One more question for Jinxsee, Suppose if we are using row_number() for a huge records it will minimize...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 6:11 am
Jinxsee (9/27/2012)
My bad! Mental note added. ^^.
No worries - now how about fixing your code so that it runs against the OP's sample data? You don't need the GROUP BY.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 5:47 am
Jinxsee (9/27/2012)
select
VALUE, YEAR, MONTH, MARK from
(select VALUE, YEAR, MONTH, MARK, ROW_NUMBER() OVER(PARTITION BY VALUE ORDER by...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 27, 2012 at 5:43 am
Viewing 15 posts - 5,536 through 5,550 (of 10,143 total)