Friday, September 27, 2013

Need help on SQL Query - COUNT

When I understand you correctly, then you either need the simple




SELECT COUNT(*) AS DSlips
FROM Doc;

when Docid is the primary key. Otherwise you need the other also simple



SELECT COUNT(DISTINCT Docid) AS DSlips
FROM DocBorrow;



The difference is: the first is simply the number of documents. The second is the number of documents which were/are borrowed.

No comments:

Post a Comment