d9cody
Starting Member
2 Posts |
Posted - 2011-08-29 : 11:01:33
|
I'm looking for a way to select a database and then run a query based on the database selected. Basically, I want to pick a client (database) and then run a query to see results just for the specified client. I want this to eventually be a spreadsheet in excel where a user can choose a client and then the workbook is updated accordingly for just that client. Any help would be appreciated, here is an example of what I have currently:-- Trim Audit PAT Data Iterationselecta.Run_ID as [Run ID],a.Trim_Audit_ID as [Trim Audit ID],a.Trim_ID as [Trim ID],a.Step,a.Target_Table as [Target Table],b.Run_Database as [Run Database],a.Trim_Step_Name as [Trim Step Name],a.Case_or_Visits as [Case or Visits],a.Case_or_Visits_Remaining as [Case or Visits Remaining],a.Case_or_Lines as [Case or Lines],a.Case_or_Lines_Remaining as [Case or Lines Remaining],a.Allowed_Amt as [Allowed Amount],a.Allowed_amt_Remaining as [Allowed Amount Remaining],a.Charges as [Charges],a.Charges_Remaining as [Charges Remaining],a.Costs,a.Costs_Remaining as [Costs Remaining],a.LOS as [Length of Stay],a.LOS_Remaining as [Length of Stay Remaining],a.Average_LOS as [Average Length of Stay],a.Average_LOS_Remaining as [Average Length of Stay Remaining],b.Run_Date as [Run Date],c.Project_Name as [Project]from Project_BCBSMT_IP_Payment_20110615_Dev.dbo.App_Trim_Audit a JOIN Treo_PAT_Repository.dbo.app_Job_Task_Log b on (a.Run_ID = b.Run_ID) --and b.Task_Order = a.Step)JOIN Treo_PAT_Repository.dbo.app_Project c on (b.Run_Database = c.Database_Name)WHERE b.Status = 'Job Ended' group by a.Trim_Audit_ID,a.Trim_ID,a.Run_ID,a.Step,a.Target_Table,a.Trim_Step_Name,a.Case_or_Visits,a.Case_or_Visits_Remaining,a.Case_or_Lines,a.Case_or_Lines_Remaining,a.Allowed_Amt,a.Allowed_amt_Remaining,a.Charges,a.Charges_Remaining,a.Costs,a.Costs_Remaining,a.LOS,a.LOS_Remaining,a.Average_LOS,a.Average_LOS_Remaining,b.Run_Date,b.Run_Database,c.Project_Nameorder by b.Run_Date descAny help would be much appreciated! Thank you-Dan-Dan Cody |
|