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 |
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2010-09-29 : 05:04:40
|
| Hi, I have a query which called qrypayamountperpatient, when I execute this query I get the result; Prac_no Amountperpatient9998 100.009998 50.001000 86.00I want to have another select query to read from the above query but giving the results; Prac_no GrossAmmount9998 150.001000 86.00Note: Since Prac_no = 9998 is the same then I sum the amountsperpatient, hence 100.00 + 50.00 = 150.00Any help please!!Many thanks |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-09-29 : 05:07:22
|
| [code]Select Prac_no,sum(Amountperpatient)from table group by Prac_no[/code]PBUH |
 |
|
|
dr223
Constraint Violating Yak Guru
444 Posts |
Posted - 2010-09-29 : 05:11:33
|
| Nice... One last thing; What if I have the following; projectID Prac_no Ampountperpatient1 9998 100.001 9998 50.001 1000 86.002 9998 115.003 7676 450.00and I would like the result to be; projectID Prac_no Ampountperpatient1 9998 150.001 1000 86.002 9998 115.003 7676 450.00Note, the sum is based if it is from the same ProjectID. Many thanks |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-09-29 : 05:31:37
|
| Select projectID,Prac_no,sum(Amountperpatient)from table group by projectID,Prac_noPBUH |
 |
|
|
|
|
|