Viewing 15 posts - 8,341 through 8,355 (of 10,143 total)
Nice work.
There are a number of different ways of achieving the same thing with TSQL, even in the version you are using. Here's one of them:
SELECT ...
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
December 16, 2009 at 5:49 am
Ryan Keast (12/16/2009)
THANK YOU!!!!
I can understand the logic from this now.
Out of intrest at the very end of the SELECT statement you have a ...
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
December 16, 2009 at 4:30 am
Try this, Ryan:
SELECT *,
[Age Range] = CASE
WHEN [Age] < 18 THEN 'Juvenile'
WHEN [Age] BETWEEN 18 AND 31 THEN '18 TO 31'
WHEN [Age] BETWEEN 32 AND 41 THEN '32 TO 41'
WHEN...
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
December 16, 2009 at 4:00 am
This should get you started, Dean:
DROP TABLE #MySampleTable
CREATE TABLE #MySampleTable (col1 INT, col2 INT, col3 INT, col4 INT, col5 INT, col6 INT, col7 INT)
INSERT INTO #MySampleTable (col1, col2, col3, col4,...
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
December 15, 2009 at 9:26 am
Ryan Keast (12/9/2009)
So take it a bit further and say if between age 25 and 48 then "25-48" and add more if I 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
December 15, 2009 at 6:53 am
This expression for returning age range bears little resemblance to TSQL:
(SELECT CASE WHEN (SELECT DATEDIFF(year, PERSON.[D-O-B], GETDATE())
- CASE
WHEN MONTH(GETDATE()) > MONTH(PERSON.[D-O-B]) THEN 0
WHEN MONTH(GETDATE()) = MONTH(PERSON.[D-O-B]) AND...
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
December 15, 2009 at 2:49 am
Something like this:
WHERE headcount = 'transfercluster'
OR headcount = CASE WHEN @Consolidate <> '(Retail Consolidate)' THEN 'TransferConsolidate' ELSE CAST(NEWID() AS CHAR(36)) END
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
December 15, 2009 at 2:39 am
You can use CASE in a WHERE clause, but that's not the problem - you are trying to construct a list on-the-fly for the IN operator. The syntax of your...
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
December 15, 2009 at 2:15 am
There's an alternative syntax which you may find more intuitive:
SELECT IDENTITY(int, 1, 1) AS RowID, ...
INTO #temp
FROM ...
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
December 14, 2009 at 9:46 am
GSquared (12/14/2009)
CirquedeSQLeil (12/11/2009)
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
December 14, 2009 at 9:41 am
GSquared (12/14/2009)
That doesn't look like T-SQL. Not sure what it is, but I doubt it's from an MS SQL database.
<<from dual>> Oracle?
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
December 14, 2009 at 8:32 am
sibir1us (12/10/2009)
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
December 14, 2009 at 6:59 am
GSquared (12/11/2009)
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
December 14, 2009 at 2:04 am
CirquedeSQLeil (12/11/2009)
As for the requirements and desired output, Chris was spot on. If this does not do exactly what you envisioned - we need to...
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
December 11, 2009 at 9:12 am
charu.verma (12/11/2009)
Thanks-but this will not workThe cloumns in Tbl3 have to be deleted tnum of tbl2,formatted tnum returned from fucntion & sid of tbl1 & not oid of tbl2
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
December 11, 2009 at 8:17 am
Viewing 15 posts - 8,341 through 8,355 (of 10,143 total)