Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sross81
Posting Yak Master
228 Posts |
Posted - 2008-10-31 : 17:16:04
|
| I have a query that needs to return a total file size. There can be multiple e.page records in the a.document table with a different size for each page. I want to return just one row with the document_id, etc and total file size. My code returns a number that is exactly double what the total file size should be. Does anyone know why this would happen?select distinct c.first_name,c.last_name,a.document_id,a.doc_number,a.create_timestamp as DateScanned,d.description,sum(e.file_size)from document a join index_value b on a.document_id= b.document_idjoin person c on b.person_id = c.person_idjoin doc_type_mstr d on a.doc_type_id = d.doc_type_idjoin page e on a.document_id = e.document_idwhere a.doc_number = '72115' and d.description IN('ultrasounds','Ultrasounds In-House')and c.person_id IN(select a.person_id from patient_encounter a join provider_mstr b on a.rendering_provider_id = b.provider_idwhere b.last_name like '%neighbor%')group by a.document_id,c.first_name,c.last_name,a.create_timestamp,d.description,a.doc_numberorder by a.create_timestamp descThanks in Advance!Sherri |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-01 : 02:20:26
|
| that may be because you've one to many relation existing between any table and because of that the data from page gets duplicated. it would be better to post your sample data from tables and also what you want as output without which its difficult to sugest as we cant see your system and neither knows how data is in your tables. Refer the link below to understand how to post a question.http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
|
|
|
|
|