The SELECT SC03001, SUM (SC03003)
, Max (case when SC03002='01' then SC03058 else 0 end) warehouse
The FROM SC03 00 '+ @ CompanyCode +'
WHERE SC03001 NOT LIKE '0 r %'
AND SC03001 NOT LIKE '00%'
GROUP BY SC03001 ORDER BY 1
CodePudding user response:
Most of the database, the table name don't support variable wayFor example, I have two tables tableA and tableB
I can only select * from tableA, select * from tableB
Not
Declare @ name
The set @ name='A'
Select * from table + @ name
Can't
Declare @ name
The set @ name='tableA'
Select * from @ name
CodePudding user response:
I just want in crystal reports is doing "FROM SC03 '+ @ CompanyCode +' 00" table to make a choice here, the main table has a formal company "DP" and "T1 test company", the query can choose the company to the query again