Viewing 15 posts - 3,526 through 3,540 (of 5,504 total)
Here's an alternative way to do it:
;WITH cte AS
(
SELECT reportqid,incidenttype,sortorder,CONVERT(CHAR(10),enddate,112) AS enddate
FROM
( SELECT *
FROM HHSDataTest
) p
UNPIVOT (sortorder FOR incidenttype IN
(
[NumFoodSvcInsPerformed],
[NumRoutineFoodSvcInsPerformed],
[NumFollowupFoodSvcInsPerformed] ,
[NumCompliantFoodSvcInsPerformed] ,
[NumTouristAccomInspections],
[NumSolidWasteInsPerformed],
[NumFacilitiesClosed]
)
) AS unpvt
),
transform AS
(
SELECT...
May 14, 2010 at 12:52 pm
MTY-1082557 (5/14/2010)
Thank you LutzIt works !
I will take at look at your article.
thank you again
My pleasure 😀
As a side note: the article I referenced in my signature is not mine....
May 14, 2010 at 9:19 am
TheSQLGuru (5/14/2010)
May 14, 2010 at 9:17 am
If you define your sour columns as character you might be able to use the following:
SELECT CAST('2010'+'-'+'1'+'-'+'15' AS DATETIME)
May 13, 2010 at 4:44 pm
The way you've arranged your tables you probably need a RIGHT OUTER JOIN to get all values from Staff.
May 13, 2010 at 4:23 pm
fawadafr (5/13/2010)
Would this be a good table definition?
SELECT .... FROM [CRMNote]
GO
Thanks for the reply!
No, since the column definition is missing. There are no ready to use sample data either...
Please...
May 13, 2010 at 4:18 pm
I would use ROW_NUMBER() OVER(PARTITION BY names, address, [basic contact info] ORDER BY hopefully_existing_rowid) as RowNmbr to identify the separate rows.
The ROW_NUMBER would be used within a CTE in order...
May 13, 2010 at 4:09 pm
Would the following help?
I'm using OVER (PARTITION BY) to get the total per idName.
Side note: Since you already using dynamic SQL you might want to have a look at the...
May 13, 2010 at 3:47 pm
Tara,
did you add any indexes after populating #EmployeeDur and Empgig1?
If not, I guess the following indexes might help:
Empgig1: EmpID,InDt include(EmpCode)
#EmployeeDur: EmpID,StDate,EnDate
Side note: Are you sure you need the DISTINCT clause...
May 13, 2010 at 1:49 pm
Excellent job, Grant!
The only question that remains open is: Where to draw the line?
But I guess it's almost impossible to answer...
Interview questions, test/homework, almost complete projects, several hundred lines of...
May 13, 2010 at 6:04 am
Jeff Moden (5/12/2010)
May 12, 2010 at 4:43 pm
Jeff Moden (5/12/2010)
I'm still believe that the use of the Tally table here would be slower across a million rows than if the codes were stored in a nice...
May 12, 2010 at 2:19 pm
I would quote the related msdn website.
AFAIK, websites are allowed as references.
e.g. http://msdn.microsoft.com/en-US/library/ms186734(v=SQL.90).aspx as a reference for the ROW_NUMBER() syntax.
I would copy the website together with a date information for...
May 12, 2010 at 1:53 pm
I second Brandie and Elliot regarding the sandbox db.
Once that person "designed" a query he/she wants to run in production, that person should send the query to one of the...
May 12, 2010 at 1:46 pm
Please re-read my previous post: I asked for your expected result based on your sample data. I can't find it...
All I see is
ROW # FIELD NAME 1 ... FIELD NAME...
May 12, 2010 at 12:33 pm
Viewing 15 posts - 3,526 through 3,540 (of 5,504 total)