number of records in a table in SQL
How to write a select statement that gets the total number of records in a table.
Criteria
Data.Reconciled = 0
Data.Filled = 1
Data.Sub_Needed = 1
Data.Deleted = 0
Must be able to provide a date range that would only look at jobs that have a contract_date in the date range provided.
Data must be grouped by Disk Name.
ISPN Name must be displayed f开发者_如何学Pythonor each line next to the Disk Name.
SELECT info.ISD, Data.ispnName, Data.diskName, COUNT(*)
FROM Data, info
WHERE Data.Reconciled = 0 AND
Data.Filled = 1 AND
Data.Sub_Needed = 1 AND
Data.Deleted = 0 AND
Data.contract_date >= 'START DATE' AND
Data.contract_date <= 'END DATE'
GROUP BY Data.diskName
select count(*) from Data where Data.Reconciled = 0 and Data.Filled = 1 and Data.Sub_Needed = 1 and Data.Deleted = 0 and Data.contract_date >= '1-1-2011' and Data.contract_date <= '12-31-2010' group by data.diskname
the actual structure of your tables would help fill in the blanks.
精彩评论