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 |
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2011-12-12 : 10:55:00
|
| I have a Query that I am grouping by TOP 100 TIN and Practice Name. The results are great, but I want to add the columns with phone, fax, emails, etc, but I don't want it to change the number count of this. How can I do that? I am new to this type of reporting. ThanksSELECT TOP (100) TIN,ProviderOffice,SUM(TOTALCHARGES) AS Total_Charges, SUM(ALLOWEDCHARGES) AS Allowed_Charges, SUM(SAVINGS) AS Total_Savings, COUNT(DISTINCT claimnumber1) AS claim_CountFROM vw_podiatryWHERE (STATEMENTFROMDATE >= '01/01/2011') AND (STATEMENTFROMDATE <= '12/01/2011') ANDState = 'PA' and SpecialtyDescription = 'podiatry'GROUP BY TIN,ProviderOfficeORDER BY Total_Charges DESC |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-12 : 11:00:50
|
| sorry your description wont make any sense to anybody who doesnt know the system. For example how do you think somebody will be able to get(guess) answers to the below questions?1. How are columns phone,fax,etc stored in table? is it in same table or related table?2. is it stored as columns itself or as rows? will it always have a value?3. when you say you cant change number count what do you mean by that? if there are multiple rows storing different phone,fax,emails etc how would you return a single row? what shuld be the rule?so in view of all these, best thing would be to post sample data and then explain what output you're expecting as given in below link http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sunnyleoneo
Starting Member
19 Posts |
Posted - 2011-12-12 : 12:09:00
|
| Please let us know table structure where phone, fax, emails, etc are stored. and also sample data will help a lot. Only after this we can help you. |
 |
|
|
|
|
|
|
|