Showing posts with label understanding. Show all posts
Showing posts with label understanding. Show all posts

Wednesday, March 28, 2012

Having Multiple ranges in the query

Hi All,
I have a problem to get this work done. I want to optimize this by
using multiple ranges in having cluase..
for the understanding i'm writing down the whole Query here ...
----
--
SELECT
DISTINCT VAR2 AS TotalCount,
Max(NetTime) as Time
FROM
XYZ
WHERE
(Talk > 0) AND (DateTime = '2006-05-15')
GROUP BY
VAR2, NetTime
Having
((NetTime > 0) AND (NetTime < 11))
----
--
I want to have data in different ranges like this in below:
0-10 11-20 21-30 31-40 41-50 51-60
61-120 Above 120
-- -- -- -- -- --
-- -- -- --
1779 1410 1109 633 569 560
1013 798
I would highly appriciate for any quick response
TIA
-- Atif Iqbal --Hi
Probably you will be better off doing such reports in the client side
"Atif Iqbal" <aatif.iqbal@.gmail.com> wrote in message
news:1147777689.050841.290500@.g10g2000cwb.googlegroups.com...
> Hi All,
> I have a problem to get this work done. I want to optimize this by
> using multiple ranges in having cluase..
> for the understanding i'm writing down the whole Query here ...
> ----
--
> SELECT
> DISTINCT VAR2 AS TotalCount,
> Max(NetTime) as Time
> FROM
> XYZ
> WHERE
> (Talk > 0) AND (DateTime = '2006-05-15')
> GROUP BY
> VAR2, NetTime
> Having
> ((NetTime > 0) AND (NetTime < 11))
> ----
--
> I want to have data in different ranges like this in below:
> 0-10 11-20 21-30 31-40 41-50 51-60
> 61-120 Above 120
> -- -- -- -- -- --
> -- -- -- --
> 1779 1410 1109 633 569 560
> 1013 798
> I would highly appriciate for any quick response
>
> TIA
> -- Atif Iqbal --
>|||This is best done client side, but something along these lines may help, if
you insist on doing it on the database. Dividing the nettime by 10 and
rounding down will give you a row for each range, although the ranges will
run from 0 to 9 for values ranging from 0 to less than 10, 10 to 19, etc.
It is not the entire solution, but may get you most of the way there. I
don't think you want the distinct in there, since the group by and count
should be handling that.
SELECT
VAR2 AS TotalCount
, count(var2)
, floor(NetTime/10) as TimeRangeLow
, floor(NetTime/10)+9 as TimeRangeHigh
FROM
XYZ
WHERE
(Talk > 0) AND (DateTime = '2006-05-15')
GROUP BY
VAR2, floor(NetTime/10)
"Atif Iqbal" <aatif.iqbal@.gmail.com> wrote in message
news:1147777689.050841.290500@.g10g2000cwb.googlegroups.com...
> Hi All,
> I have a problem to get this work done. I want to optimize this by
> using multiple ranges in having cluase..
> for the understanding i'm writing down the whole Query here ...
> ----
--
> SELECT
> DISTINCT VAR2 AS TotalCount,
> Max(NetTime) as Time
> FROM
> XYZ
> WHERE
> (Talk > 0) AND (DateTime = '2006-05-15')
> GROUP BY
> VAR2, NetTime
> Having
> ((NetTime > 0) AND (NetTime < 11))
> ----
--
> I want to have data in different ranges like this in below:
> 0-10 11-20 21-30 31-40 41-50 51-60
> 61-120 Above 120
> -- -- -- -- -- --
> -- -- -- --
> 1779 1410 1109 633 569 560
> 1013 798
> I would highly appriciate for any quick response
>
> TIA
> -- Atif Iqbal --
>

Wednesday, March 7, 2012

hard time understanding the execution plans

SQL server 2005 has a really complicated execution plans that I am really unable to compare two execution plans with each other cumulative.

I can easliy see by eye that one execution plan is slower than the other but is there anyway to compare two execution plans in sql 2005?

Hi,

I'm afraid there is no comparison tool. Here is a reference to the items in the Execution Plan: http://msdn2.microsoft.com/en-us/library/ms175913.aspx. Hope it helps.

Greetz,

Geert

Geert Verhoeven
Consultant @. Ausy Belgium

My Personal Blog

|||True, either you can export the text based to a file for a comparison or search for any third party tools on web in this regard.|||

my problem is query execution plan does not help me understand the bottlenecks in the system as I can't compare with any realistic thing against.

how do u guys solve this problem? How do u decide that this is a decend query or say this is a bad one?

|||Here are some tips:
Remember that the thickness of arrows hints how many rows are transferred|||

thanks for the tips they are GREAT.

I will look into statistics IO