Viewing 15 posts - 4,486 through 4,500 (of 10,144 total)
dwain.c (6/17/2013)
ChrisM@Work (6/17/2013)
This runs about 4 times faster than the original against the sample data set.
SELECT
w.ID,
Wage = MIN(w.Wage),
Sector = MIN(w.Sector),
tw = MIN(a.tw)
FROM #WageData w
INNER...
June 18, 2013 at 3:31 am
Ramp up the output row count to about a quarter million and blackhole the output (an attempt to eliminate io from the execution time), and a tally table version runs...
June 18, 2013 at 3:20 am
Chrissy321 (6/17/2013)
I will be joining multiple...
June 18, 2013 at 2:01 am
dwain.c (6/17/2013)
...
This seems to a bit simpler and works with the sample data:
SELECT ID, Wage=MAX(Wage), Sector=MIN(Sector), tw=SUM(Wage)
FROM #WageData
GROUP BY ID
Did I miss something?
Well I'll be darned...nice one, Dwain. Must have...
June 18, 2013 at 1:33 am
T.Ashish (6/17/2013)
this is the actual plan from prod server.
Thanks for posting.
I'd recommend you implement the indexes I posted earlier and repost the actual plan from prod with the indexes...
June 18, 2013 at 1:23 am
There's another element to this issue here. The OP has a calendar table but is unsure how to plug it into the query above.
June 17, 2013 at 9:00 am
TheSQLGuru (6/17/2013)
T.Ashish (6/17/2013)
...
June 17, 2013 at 8:53 am
A randomly-selected work from a number of randomly-selected authors:
SELECT
WORKID,
AUTHORID
FROM (
SELECT TOP 10
AUTHORID
FROM dbo.LITERARYWORKS
GROUP BY MASTNUM
ORDER BY NEWID()
) at
CROSS APPLY (
SELECT TOP 1
WORKID
FROM...
June 17, 2013 at 6:31 am
Hi Amy
This runs about 4 times faster than the original against the sample data set.
SELECT
w.ID,
Wage = MIN(w.Wage),
Sector = MIN(w.Sector),
tw = MIN(a.tw)
FROM #WageData w
INNER JOIN (
SELECT...
June 17, 2013 at 5:10 am
T.Ashish (6/17/2013)
I...
June 17, 2013 at 4:23 am
-- try changing this
OUTER APPLY (
SELECT
active_users = SUM(CASE WHEN activity_flag = 1 AND reg_flag = 0 THEN 1 ELSE 0 END),
new_users = SUM(CASE WHEN activity_flag = 1 AND reg_flag...
June 17, 2013 at 4:08 am
The result set from your second query already contains all of the columns in your requested output. What do you want to change?
Your first query is quite inefficient. The table...
June 17, 2013 at 3:19 am
Why read the persons table three times when you only have to read it once?
SELECT
activity_flag = case when comp.activity_flag = 1 then 'Active' else 'Inactive' end,
comp.name,
comp.comp_code,
x1.active_users,
x1.new_users,
x1.inactive_users,
worker = (select count(1)
from...
June 17, 2013 at 2:12 am
Hands up if you find this easier to scan:
SELECT
o.ID,
PAYREAL = ISNULL(SUM(o.VALPAYREAL),0),
PAYPLAN = ISNULL(SUM(o.VALPAYPLAN),0),
x.PAYPLANTODATE,
PAYPROCESS = ISNULL(SUM(o.VALPAYPROCESS),0)
FROM ABC o
CROSS APPLY (
SELECT
...
June 14, 2013 at 4:26 am
You're welcome, and thanks for the feedback. Sorry I didn't get back to you on your second question, I'm on UK time.
June 14, 2013 at 1:02 am
Viewing 15 posts - 4,486 through 4,500 (of 10,144 total)