Viewing 15 posts - 3,211 through 3,225 (of 5,504 total)
Step one: Define a column to be used as a row/column identifer (either column Parameter or a new column using ROW_NUMBER())
Step two: UNPIVOT the data to get a table with...
July 3, 2010 at 11:06 am
I would precalculate the data per user and day using a CTE or subquery.
; WITH cte AS
(
SELECT ServiceID ,
COUNT(DISTINCT DATE) AS cnt,
SUM(numHours) AS subtotal
FROM @ServiceDates
GROUP BY ServiceID, UserName
)
SELECT L.ClientID, S.LocationID,...
July 3, 2010 at 10:54 am
Paul White NZ (7/2/2010)
lmu92 (6/30/2010)
The best one I've seen so far is by Jeff Moden and posted here.
Interesting. Even though I am credited on that post with a...
July 2, 2010 at 9:12 am
Would the following code give you the expected result?
SELECT
CASE WHEN (Grouping(Store) = 1) THEN 'Report Total' ELSE Store END AS report_total,
Product,
Store,
CASE WHEN (Grouping(Store) = 1) THEN...
July 1, 2010 at 4:46 pm
Here's an alternative to Waynes second query.
Depending on the data structure of the xml file it might perform better.
-- to get all KeyTypes for the user, different approach:
SELECT...
July 1, 2010 at 4:37 pm
Assuming you're using SQL2000 then the following approach might help:
SELECT
User_ID as Field1,
'Monday' as Weekday,
Prg_Hrs_Monday=Prj_Hrs
FROM YourTable
UNION ALL
SELECT
User_ID as Field1,
'Tuesday' as Weekday,
Prg_Hrs_Tuesday=Prj_Hrs
FROM...
July 1, 2010 at 4:21 pm
Any chance to be a little more specific?
E.g. by providing table def and sample data of the table involved together with a few scenarios to cover?
This would actually help us...
July 1, 2010 at 4:13 pm
Triple post.
So far, most replies here.
July 1, 2010 at 4:06 pm
GilaMonster (7/1/2010)
July 1, 2010 at 2:37 pm
Some posters sure have a strange perspective regarding performance...
July 1, 2010 at 2:18 pm
chris-736523 (7/1/2010)
lmu92,
I tested both versions in question above. Both return more than 1000 values in less than 1 second. If you want to split hairs, can you...
July 1, 2010 at 2:12 pm
chris-736523 (6/30/2010)
I'll declare the input parameter as
@ParameterName VARCHAR(4000)
Then, whatever is calling the procedure needs to pass a comma delimited string of values. Example "1,2,3,4,5,6".
In...
June 30, 2010 at 4:27 pm
What exactly is your question? :unsure:
June 30, 2010 at 4:16 pm
Based on your sample data, wouldn't it simply be
SELECT cust_num, SUM(dayslate) AS res
FROM mytable
WHERE [TYPE]='P'
GROUP BY cust_num
June 30, 2010 at 4:13 pm
If you're using SQL Server 2008 you could pass the values as a table variable parameter.
An example is given here.
Regarding "ALL records": it depends how you pass the data...
June 30, 2010 at 2:32 pm
Viewing 15 posts - 3,211 through 3,225 (of 5,504 total)