If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How find the record count from SQL output ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-26-02, 10:31
matkwan matkwan is offline
Registered User
 
Join Date: Jul 2002
Posts: 6
How find the record count from SQL output ?

Hi, I want to find out how many records return from the SQL, I have tried this but didn't work, please help. Thanks Matt

Select Count(CountOfQuote_ID) From (SELECT Count(tbl_Quotes.Quote_ID) AS CountOfQuote_ID, Format(tbl_Quotes.Quote_Date, "mmm yyyy") AS MonthYear, Year(tbl_Quotes.Quote_Date) AS YearDate, Month(tbl_Quotes.Quote_Date) AS MonthDate
FROM tbl_Quotes
GROUP BY Format(tbl_Quotes.Quote_Date, "mmm yyyy"), Year(tbl_Quotes.Quote_Date), Month(tbl_Quotes.Quote_Date)
ORDER BY Year(tbl_Quotes.Quote_Date), Month(tbl_Quotes.Quote_Date)))
Reply With Quote
  #2 (permalink)  
Old 07-26-02, 10:38
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Reply With Quote
  #3 (permalink)  
Old 07-26-02, 11:00
matkwan matkwan is offline
Registered User
 
Join Date: Jul 2002
Posts: 6
Sorry Rudy, I don't get it. Do you mind using your way to change my code and show me this solution ?

Thanks
Matt
Reply With Quote
  #4 (permalink)  
Old 07-26-02, 12:19
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
   SELECT Count(tbl_Quotes.Quote_ID) 
            AS CountOfQuote_ID
        , Format(tbl_Quotes.Quote_Date, "mmm yyyy") 
            AS MonthYear
        , Year(tbl_Quotes.Quote_Date) 
            AS YearDate
        , Month(tbl_Quotes.Quote_Date) 
            AS MonthDate 
     FROM tbl_Quotes 
 GROUP BY Format(tbl_Quotes.Quote_Date, "mmm yyyy")
        , Year(tbl_Quotes.Quote_Date)
        , Month(tbl_Quotes.Quote_Date) 

UNION ALL

   SELECT Count(tbl_Quotes.Quote_ID) 
        , "---Total"
        , 9999
        , 99
     FROM tbl_Quotes 

 ORDER BY 3
        , 4
note that ORDER BY 3,4 is year, month -- this is deprecated but should work in most databases
Reply With Quote
  #5 (permalink)  
Old 08-02-02, 05:33
brtn brtn is offline
Registered User
 
Join Date: Aug 2002
Posts: 1
Lightbulb known

Quote:
Originally posted by matkwan
Sorry Rudy, I don't get it. Do you mind using your way to change my code and show me this solution ?

Thanks
Matt
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On