Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

help using getdate function Expand / Collapse
Author
Message
Posted Thursday, May 6, 2010 2:42 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 20, 2013 11:18 AM
Points: 35, Visits: 235
select



Distinct ClientIdentifier, sourcesystem, methodtype, voicedatatype, Count(*) as ErrorCount

from



[logsserver].[uCSRLogs].[Logs].[tNACRTransaction] WITH(NOLOCK)

where







convert(char(8), dtmdatecreated, 112) = convert(char(8), GETDATE()-1, 112)



and messagetype like 'RESP%'



and outputResponse not like '%D000000%'



and methodtype <> 'UpdateAccountTerm'



and ClientIdentifier in ('COG', 'COG_WB', 'COPPERNET', 'COFEE','NCOG', 'NSOP', 'LSOP', 'SSP', 'SSP_DL', 'VOSE', 'UCSR', 'UCSR-ORDER')

group



by ClientIdentifier, sourcesystem, methodtype, VoiceDataType

order



by ClientIdentifier, methodtype





can u pls tell me this query give me result of getdate()...



i want for today(getdate), getdate()-1 and total count from yesterday-7....



i want 2 more columns needed for getdate()-1 and yesterday-7
Post #917435
Posted Thursday, May 6, 2010 2:48 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:56 AM
Points: 20,815, Visits: 32,748
Slightly confused, exactly what are you looking for here, a count of records for today, yesterday, and the past 7 days excluding today?



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #917438
Posted Thursday, May 6, 2010 2:53 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 20, 2013 11:18 AM
Points: 35, Visits: 235
EG.. i want error count for today mean wed,tue mean yesterday and total errorcount from wed(today) till last wed...
Post #917441
Posted Thursday, May 6, 2010 3:26 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:56 AM
Points: 20,815, Visits: 32,748
Still confused, so here is some code. Work with it and see if it solves your problem. You may need to tweak it some, you didn't provide anything to allow us to test our code or results against.

For help on asking for help, please read the first article I reference below in my signature block. Follow the instructions in that article, plus provide the expected results as well, and you will get people tripping over themselves to help AND get tested code in return.

select
ClientIdentifier,
sourcesystem,
methodtype,
voicedatatype,
sum(case when dtmdatecreated >= dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime)) and
dtmdatecreated < dateadd(dd, 1, dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime)))
then 1
else 0
end) ErrorCountToday,
sum(case when dtmdatecreated >= dateadd(dd, -1, dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime))) and
dtmdatecreated < dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime))
then 1
else 0
end) ErrorCountYesterday,
sum(case when dtmdatecreated >= dateadd(dd, -1, dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime))) and
dtmdatecreated < dateadd(dd, -7, dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime)))
then 1
else 0
end) ErrorCountLast7Days
from
[logsserver].[uCSRLogs].[Logs].[tNACRTransaction] WITH(NOLOCK)
where
dtmdatecreated >= dateadd(dd, -7, dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime)))
and dtmdatecreated < dateadd(dd, 1, dateadd(dd, datediff(dd, cast('19000101' as datetime), getdate), cast('19000101' as datetime)))
and messagetype like 'RESP%'
and outputResponse not like '%D000000%'
and methodtype <> 'UpdateAccountTerm'
and ClientIdentifier in ('COG', 'COG_WB', 'COPPERNET', 'COFEE','NCOG', 'NSOP', 'LSOP', 'SSP', 'SSP_DL', 'VOSE', 'UCSR', 'UCSR-ORDER')
group by
ClientIdentifier,
sourcesystem,
methodtype,
VoiceDataType
order by
ClientIdentifier,
methodtype;




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #917462
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse