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 |
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2014-03-14 : 11:57:05
|
Hey Guys Your well I need some assistance I have created the following query SELECT 'Total Outlets', count(FDMSAccountNo) as TotalFROM [FDMS].[dbo].[Dim_Merchant_Log_All]where FDMSAccountNo <> Chain_Chain_Noand FDMSAccountNo <> Corp_Chain_Noand FDMSAccountNo <> Agent_Chain_Noand Period = 201401Which produces the following (No column name) TotalTotal Outlets 172787I have also created the following query SELECT 'Total Outlets',count(distinct(dla.FDMSAccountNo)) as Non_ISO_TotalFROM Dim_Merchant_Log_All DLAINNER JOIN Dim_Outlet ON DLA.Agent_Chain_No = Dim_Outlet.Agent_Chain_Nowhere DLA.FDMSAccountNo <> DLA.Chain_Chain_Noand DLA.FDMSAccountNo <> DLA.Corp_Chain_Noand DLA.FDMSAccountNo <> DLA.Agent_Chain_Noand ISO_Account = 'N'and Period = 201401which produces the following (No column name) ISO_TotalTotal Outlets 71364What i want to do is attached the total outlets on the ISO total onto the total outlets totalRequired results(No column name) Total ISO_TotalTotal Outlets 172787 71364looking forward to your help |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-03-14 : 13:59:06
|
Here is one way to do that:SELECT 'Total Outlets', ( SELECT count(FDMSAccountNo) FROM [FDMS].[dbo].[Dim_Merchant_Log_All] where FDMSAccountNo <> Chain_Chain_No and FDMSAccountNo <> Corp_Chain_No and FDMSAccountNo <> Agent_Chain_No and Period = 201401) AS Total,( SELECT count(distinct(dla.FDMSAccountNo)) FROM Dim_Merchant_Log_All DLA INNER JOIN Dim_Outlet ON DLA.Agent_Chain_No = Dim_Outlet.Agent_Chain_No where DLA.FDMSAccountNo <> DLA.Chain_Chain_No and DLA.FDMSAccountNo <> DLA.Corp_Chain_No and DLA.FDMSAccountNo <> DLA.Agent_Chain_No and ISO_Account = 'N' and Period = 201401) AS Non_ISO_Total |
 |
|
|
|
|