Solved

get count

Posted on 2008-06-16
6
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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