Solved

get count

Posted on 2008-06-16
6
179 Views
Last Modified: 2010-04-21
based on the query below, i now need to add to it and get a count of how many is in each day

example
Mon/16 (5)  <---- 5 is the count of how many Mon 16 is in the query
Sat/14 (3)

below produces

Mon/16
Sat/14

        SELECT  distinct CONVERT(VARCHAR(10), TIMEDATE , 120) as varDate
        FROM orders
        WHERE year(TIMEDATE)  = YEAR('#datepassed#')
        AND month(TIMEDATE)  = month('#datepassed#')
        ORDER BY varDate DESC
0
Comment
Question by:pigmentarts
  • 3
  • 2
6 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 400 total points
ID: 21796734
       SELECT  CONVERT(VARCHAR(10), TIMEDATE , 120) as varDate, count(*)
        FROM orders
        WHERE year(TIMEDATE)  = YEAR('#datepassed#')
        AND month(TIMEDATE)  = month('#datepassed#')
        group by CONVERT(VARCHAR(10), TIMEDATE , 120)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 21796805
what is the variable for count so i can output it?  varDate  (which i need) gives me the date not the count
0
 
LVL 31

Assisted Solution

by:James Murrell
James Murrell earned 100 total points
ID: 21796846
 SELECT  CONVERT(VARCHAR(10), TIMEDATE , 120) as varDate, count(*)as countnumber
        FROM orders
        WHERE year(TIMEDATE)  = YEAR('#datepassed#')
        AND month(TIMEDATE)  = month('#datepassed#')
        group by CONVERT(VARCHAR(10), TIMEDATE , 120)

I think
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 12

Author Comment

by:pigmentarts
ID: 21796855
ok seems to work with the following is this ok code?

       SELECT  CONVERT(VARCHAR(10), TIMEDATE , 120) as varDate, count(order_id) as varCount
        FROM orders
        WHERE year(TIMEDATE)  = YEAR('#datepassed#')
        AND month(TIMEDATE)  = month('#datepassed#')
        group by CONVERT(VARCHAR(10), TIMEDATE , 120)
       ORDER BY varDate DESC
0
 
LVL 31

Expert Comment

by:James Murrell
ID: 21796867
yes, but note chapmandew did the hard work...
0
 
LVL 12

Author Closing Comment

by:pigmentarts
ID: 31467736
thanks both of you
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now