I need to retrieve the count of selected rows for two joined tables with few distinct columns using Concat function in MSSQL database.
The normal query is something like below:
select DISTICNCT ST.DummyDate,(TT.DummyOffice+'-'+TT.DummyRegionSubType),FT.DummyOrganization,ST.DummyCode from FirstTable FT join SecondTable ST on FT.CustomerCode=ST.DummyCode and FT.DummyOrganization=ST.DummyOrganization
I tried with the following, but didn’t worked.
select count(*) from (select DISTICNCT ST.DummyDate,(TT.DummyOffice+'-'+TT.DummyRegionSubType),FT.SalesOrganization,ST.DummyCode from FirstTable FT join SecondTable ST on FT.CustomerCode=ST.DummyCode and FT.DummyOrganization=ST.DummyOrganization ) as Count
Any thoughts would be much appreciated.