Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Total Records When Child Table Has a Value 1

Status
Not open for further replies.

tekdudedude

Technical User
Sep 29, 2007
79
0
0
Hello,

In an Oracle 10g database I have two tables: documents and document_pages. The document_pages is a child table to the documents table. The document_pages table has a varchar2 type field where the values are either: 'HTML' or 'TEXT'.

What SQL can I use to get a count of how many document's contain 'HTML'?


Thanks,

TD
 
select count(docs.*) from documents docs, document_pages docpgs where docs.some_id = docpgs.some_id and docpgs.doc_type = 'HTML'
 
get a count of how many document's contain 'HTML'
SELECT COuNT(*)
FROM document_pages
WHERE type = 'HTML'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
get a count of how many documents contain 'HTML'
SELECT COUNT(DISTINCT doc_id)
FROM document_pages
WHERE type = 'HTML'

:)

r937.com | rudy.ca
 
All very good posts. Thanks all. :)

r937's was the ideal SQL for what I am doing.

Thanks again,

TD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top