php - Creating a table from query -
here 2 sql query on first query want use table , on 2nd query want join 1st query assume table
e.g.
first query:
select sale.salesmanid, sale.companyname, sale.sellingprice sale inner join carmodel on (sale.companyname = carmodel.companyname) , (carmodel.size>10) ;
second query:
select salesman.salesmanid, salesman.name, sum(firstquery.sellingprice) salesman inner join firstquery on salesman.salesmanid = firstquery.salesmanid group salesmanid, name;
how can ? in advance.
if understand question correctly (although i'm not sure why you'd want way...):
if object_id('tempdb..#firstquery) not null drop table #firstquery;
select sale.salesmanid, sale.companyname, sale.sellingprice #firstquery sale inner join carmodel on (sale.companyname = carmodel.companyname) , (carmodel.size>10) ;
select salesman.salesmanid, salesman.name, sum(firstquery.sellingprice) salesman inner join #firstquery on salesman.salesmanid = firstquery.salesmanid group salesmanid, name;
Comments
Post a Comment