SQL Combining 2 result sets in an ordered way -
Can someone order 2 questions in the same result set?
More specifically, if I had 2 queries:
select 'line', product, numerical_with numbered orders by product; Select 'Total', Product, Sum (numeric_free) from the numbered group by product; There is one way to combine two questions, so that the result set will look like this:
Type product numeric_value line item 1 23 line item 1 57 Line items 1 23 total items 1 103 line items 5 20 line items 5 50 line items 560 total items 5 130 ... Basically, I'm looking at a list of all item records of a product, then show them an amount for them, Then the list of all item records of the next product, etc. Doing this Is there any way, or is this an impossible task? Thank you :)
In many databases, you can do this with rollup However, since you have received it: from the select * (select the 'line', the product, numeric value of the numerical value) union all ('total', product, Choose the amount Numeric_value) from the numbered group by the product)) Order ordered by the product, which order by product , which , together with all the product lines. So is "total" is the ultimate cause of order.
Comments
Post a Comment