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 - 2007-11-30 : 08:51:04
|
| I hope you can help me out here. I don't know if I even have enough information to give you. I need to create a SQL that pulls the most commonly Billed CPT Codes. The Fields that I am going to use is the CPTCODES Field and the DOS FROM Field. How I was going to right my statement is below. Do I need to have a count or anything?SELECT TOP 100 DOSFROM, DOSThru, CPTCODESFROM VW_1000_Commonly_Billed_ChargesWHERE (DOSFROM >= @BottomDate) AND (DOSThru <= @TopDate) |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-11-30 : 14:14:58
|
| You should define the term "most commonly Billed CPT Codes". I am guessing you need to use a GROUP BY and get the count and select the top X.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2007-11-30 : 15:26:30
|
Yeah I think I do need to group by the cpt codes and do a count of how many pull in a date range, say 01-01-2007 through 11-29-2007. You should define the term "most commonly Billed CPT Codes". I am guessing you need to use a GROUP BY and get the count and select the top X.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/[/quote] |
 |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-11-30 : 16:24:33
|
| SELECT CPTCODES, count(*)FROM VW_1000_Commonly_Billed_ChargesWHERE (DOSFROM >= @BottomDate) AND (DOSThru <= @TopDate)group by CPTCODESorder by count(*) desc |
 |
|
|
|
|
|