Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7189637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:20:40+00:00 2026-05-28T19:20:40+00:00

Currently my query is resulting in the [CountAccns] field it is returning the monthly

  • 0

Currently my query is resulting in the [CountAccns] field it is returning the monthly count but I need the daily count!

;with
cte_biggie ( [Full Date],     [Year Entered],   [Month Entered],  [Day Entered],      
[DOW],      [Week Ending] ,[CountAccns],[Sales Rep],   [MLNPI], [IMSNPI],     [Physician],      
[Practice Code],  [MLIS Code],      [Practice Name],  
[Date Established],     [Address],  [Address2], [City],     [State],    [Status]
) as (
select CONVERT(VARCHAR(8), [DATE entered], 1),DATEPART(yy, [DATE entered]) ,  
CASE WHEN DATEPART(mm, [DATE entered]) = 01 THEN 'Jan' 
           WHEN DATEPART(mm, [DATE entered]) = 02 THEN 'Feb'
           WHEN DATEPART(mm, [DATE entered]) = 03 THEN 'Mar'
           WHEN DATEPART(mm, [DATE entered]) = 04 THEN 'Apr'
           WHEN DATEPART(mm, [DATE entered]) = 05 THEN 'May'
           WHEN DATEPART(mm, [DATE entered]) = 06 THEN 'Jun'
           WHEN DATEPART(mm, [DATE entered]) = 07 THEN 'Jul'
           WHEN DATEPART(mm, [DATE entered]) = 08 THEN 'Aug'
           WHEN DATEPART(mm, [DATE entered]) = 09 THEN 'Sep'
           WHEN DATEPART(mm, [DATE entered]) = 10 THEN 'Oct'
           WHEN DATEPART(mm, [DATE entered]) = 11 THEN 'Nov'
           WHEN DATEPART(mm, [DATE entered]) = 12 THEN 'Dec'
           END
           ,DATEPART(dd, [DATE entered]),

           case when DATEPART(WEEKDAY, [DATE entered])=1 THEN 'Sun'
           when DATEPART(WEEKDAY, [DATE entered])=2 THEN 'Mon'
           when DATEPART(WEEKDAY, [DATE entered])=3 THEN 'Tus'
           when DATEPART(WEEKDAY, [DATE entered])=4 THEN 'Wed'
           when DATEPART(WEEKDAY, [DATE entered])=5 THEN 'Thu'
           when DATEPART(WEEKDAY, [DATE entered])=6 THEN 'Fri'
           when DATEPART(WEEKDAY, [DATE entered])=7 THEN 'Sat'
           end,
           CONVERT(VARCHAR(8), DATEADD (D, -1 * DatePart (dw,[date entered]) + 6, [date entered]), 1),
            count(a.[specimen id]) ,c.salesrep,c.npi,e.npib,[Requesting Physician] ,
           a.[practice code],b.[mlis practice id],[practice name],

   c.dateestablished , c.practiceaddress1, c.practiceaddress2,c.practicecity,c.practicestate,
    b.[Active Inactive]
from quicklabdump a
    left outer join qlmlismapping b
    on (b.[practice code] = a.[practice code])
    left outer join PracticeandPhysician c
    on (a.[Requesting Physician]=c.doctorfirstname+' '+c.DOCTORLASTNAME
    and a.[practice code]=c.practicecode)
    left outer join TestResults d 
    on a.QuickLabDumpID = d.QuickLabDumpID
    left outer join IMSData e
    on c.NPI=e.npib
where    [Date Entered] <= '20111231'
and [Date Entered] >= '20111201'


group by [DATE entered],DATEPART(yy, [DATE entered]), DATEPART(mm, [DATE entered]),DATEPART(dd, [DATE entered]), a.[practice name],b.[mlis practice id],a.[practice code],
    a.[Requesting Physician],c.salesrep,c.dateestablished, c.practicecity,c.practicestate,c.npi,e.npib,c.practiceaddress1 ,c.practiceaddress2,
    b.[Active Inactive]


)

select * from cte_biggie

** how do I return the daily CountAccns count instead of the monthly?**

I believe that the main issue is with my GROUP BY, but I dont know how to solve it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:20:41+00:00Added an answer on May 28, 2026 at 7:20 pm

    I am not certain of your data structure but It doesn’t seem possible to get what you are after, for instance if records exist for more than one sales rep at the same practice code the only way to show both the sales reps is to have more than one row of data for that practise code…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a query similar to: SELECT users.fname, users.lname, sales.date FROM users LEFT
I'm investigating Zend Framework and currently stucked in counting resulting rows of sql query...
Given the following query: SELECT M.year, COUNT(C.eid) FROM Card AS C, Month AS M
Is there any way to use AppleScript (or something else) to query currently running
I currently have a query that looks like this: SELECT NON EMPTY ([Measures].[TOTAL]) ON
I'm currently doing this query to find the guy who makes the most calls:
I've currently got a query that selects metrics data from two tables whilst getting
I am currently executing AJAX query stores on each onblur if this.value is not
I have a select query that currently produces the following results: Description Code Price
Hey guys I have a query that currently finds the latest comment for each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.