all groups > sql server mseq > november 2006 >
You're in the

sql server mseq

group:

Improve Query


Improve Query No Donut For Me
11/4/2006 12:00:00 AM
sql server mseq:
Is it possible to create a query that returns a count of each
application_request_detail_status_type_id as columns?

Any help on this would be greatly appreciated, thanks :)
Re: Improve Query Arnie Rowland
11/4/2006 1:05:34 AM
SELECT count(application_request_detail_status_type_id)
FROM MyTable


....Somehow, I think that you have a different question in mind, but it is
difficult to guess what it may have been.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

Re: Improve Query Arnie Rowland
11/4/2006 3:39:56 PM
I assume you have a good indexing strategy. Not knowing the quantity of data
involved, I would consider that for the first query, you 'should' have these
columns indexed:

type.application_request_status_type_id
req.application_request_status_type_id
req.application_id
req.application_request_id
app.application_id

And for the second, these additional columns indexed:

det.application_request_detail_status_type_id
det.status_desc
req.application_request_detail_status_type_id

And my name is 'Arnie' -NOT 'Arnold'. (How's Philly these days?)

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

Re: Improve Query No Donut For Me via SQLMonster.com
11/4/2006 9:34:33 PM
Arnold,

You are right, my apologies for not being clear. I wanted to know on how to
improve a query to monitor automation jobs. Below are 2 queries being used
at the moment:

/***this query shows last 10 runs of an application with the status***/
SELECT top 10 app.application_id, app.application_desc, req.
application_request_id, req.items_count, req.items_processed, req.start_time,
req.end_time, type.application_request_status_type_desc as 'Last Status'
FROM automation..application_request req
join automation..application_request_status_type type
ON type.application_request_status_type_id = req.
application_request_status_type_id
join automation..application app ON app.application_id = req.application_id
WHERE req.application_id = 2
ORDER BY req.application_request_id desc

-AND-

/***this query shows failed/successful transactions. It queries a count of
each application_request_detail_status_type_id for an
application_request_id***/
SELECT req.application_request_id, req.
application_request_detail_status_type_id, det.status_desc, count (req.
application_request_detail_status_type_id) as 'count'
FROM automation..application_request_detail req
join automation..application_request_detail_status_type det
ON det.application_request_detail_status_type_id = req.
application_request_detail_status_type_id
WHERE req.application_request_id = 4745
GROUP BY req.application_request_id, req.
application_request_detail_status_type_id, det.status_desc





[quoted text, click to view]

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-mseq/200611/1
Re: Improve Query No Donut For Me via SQLMonster.com
11/6/2006 12:00:00 AM
Thanks a bunch Arnie...



[quoted text, click to view]

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-mseq/200611/1
AddThis Social Bookmark Button