October 12, 2009 at 8:08 am
SELECT
cv.DischargeDtm as Discharged,
count(cd.IsIncomplete)#incomplete
FROM CV3ClientVisit cv (nolock)
INNER JOIN CV3ClientDocument cd ON cv.GUID = cd.ClientVisitGUID
WHERE cv.TypeCode = 'inpatient'
and cd.documentname like 'kbc%profile'
and cd.isincomplete = 1
and cv.visitstatus = 'dsc'
and cv.admitdtm <= getdate()-1 /*used to eliminate patients admitted on current date. Nurses have 24 hours
post admission to complete the profiles */
and cv.currentlocation not like 'loa%' -- excludes the test unit
Group BY cv.DischargeDtm
October 12, 2009 at 8:11 am
And the question is ?
October 12, 2009 at 8:13 am
4:1 odds it is on the group predicate.
Anyone want to take that bet on 😀
--------------------------------------------------------------------------------------
[highlight]Recommended Articles on How to help us help you and[/highlight]
[highlight]solve commonly asked questions[/highlight]
Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
Managing Transaction Logs by Gail Shaw[/url]
How to post Performance problems by Gail Shaw[/url]
Help, my database is corrupt. Now what? by Gail Shaw[/url]
October 12, 2009 at 8:15 am
GROUP BY convert(varchar(6),getdate(),112)
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 12, 2009 at 8:17 am
Silverfox (10/12/2009)
4:1 odds it is on the group predicate.Anyone want to take that bet on 😀
I'll go for "whats then velocity of an unladen swallow" 😀
October 12, 2009 at 8:22 am
Thank you Bob and everyone else problem solved.
October 12, 2009 at 8:35 am
European or African swallow?
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 12, 2009 at 9:46 am
Bob Hovious 24601 (10/12/2009)
GROUP BY convert(varchar(6),getdate(),112)
I'd have gone
GROUP BY DATEADD(dd,datediff(dd,0,cv.Dischargedtm),0)
but that's because I hate to convert pretty things like datetimes into varchars...
October 12, 2009 at 10:40 am
Your way would definitely save a few CPU cycles, but shouldn't it be
GROUP BY DATEADD(month,datediff(month,0,cv.Dischargedtm),0)
??
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 12, 2009 at 10:49 am
Bob Hovious 24601 (10/12/2009)
Your way would definitely save a few CPU cycles, but shouldn't it beGROUP BY DATEADD(month,datediff(month,0,cv.Dischargedtm),0)
??
That would group them into monthly buckets... since it seems to be about daily discharge dates, I figured grouping them on the day of discharge was good enough.
October 12, 2009 at 10:58 am
I have the following code. I would like to group on Month and year. I have tried converting datetime to varchar to change the format.That did not work. Running the script now returns one row for every day. Any assistance would be appreciated.
This is the subtext appended when you look at the list of topics.... unfortunately it doesn't display when you look at the topic itself.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 12, 2009 at 11:08 am
Without a question from the OP , we shall never know 🙂
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply