SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


help using getdate function


help using getdate function

Author
Message
san-1015392
san-1015392
SSC Rookie
SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)

Group: General Forum Members
Points: 41 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
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39049 Visits: 38518
Slightly confused, exactly what are you looking for here, a count of records for today, yesterday, and the past 7 days excluding today?

Cool
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)
san-1015392
san-1015392
SSC Rookie
SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)

Group: General Forum Members
Points: 41 Visits: 235
EG.. i want error count for today mean wed,tue mean yesterday and total errorcount from wed(today) till last wed...
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39049 Visits: 38518
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;



Cool
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)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search