1

i have three tables table1, table2, and table3. And following is my stored procedure. after executing the stored procedure i got the following out put.

alter PROCEDURE test

    @SDate datetime,
    @EDate datetime

As

    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    Select count(quoteid) as TotalQuote, sum(totalamount) as QuoteAmount from dbo.QuoteBase
    where CreatedOn BETWEEN @SDate AND @EDate

    select  count(salesorderid)as TotalOrders, sum(totalamount) as OrderAmount from dbo.SalesOrderBase Where
    CreatedOn BETWEEN @SDate AND @EDate

    select count(opportunityid)as TotalSales  from dbo.OpportunityBase Where
    CreatedOn BETWEEN @SDate AND @EDate


GO

Output image

but i don't want to display the query result separately.

How can i done the job so that the query results will be in a single line?

4

1 回答 1

1
SELECT * FROM (Select count(quoteid) as TotalQuote, sum(totalamount) as QuoteAmount from     dbo.QuoteBase where CreatedOn BETWEEN @SDate AND @EDate)
CROSS JOIN (select  count(salesorderid)as TotalOrders, sum(totalamount) as OrderAmount from dbo.SalesOrderBase Where CreatedOn BETWEEN @SDate AND @EDate)
CROSS JOIN (select count(opportunityid)as TotalSales  from dbo.OpportunityBase Where
CreatedOn BETWEEN @SDate AND @EDate)

或者更容易,

只需做一个:

SELECT * FROM table1, table2, table3

其中 table1,2 和 3 是您的选择。

希望能帮助到你

于 2013-05-31T15:23:30.353 回答