Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
eurob
Posting Yak Master
100 Posts |
Posted - 2006-02-09 : 16:14:14
|
| How can I compute the result of the subquery ?select client,(select sum(b) from subtable) from maintable --> how can i get this in my compute by clause ?? order by clientcompute sum(?????)robert |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-02-10 : 01:08:48
|
quote: from bolThe COMPUTE BY clause generates subtotals within a result set; the COMPUTE clause generates a total at the end of the result set. The SQL Server ODBC driver presents these totals and subtotals to the calling application by generating multiple result sets for each SELECT statement.The following example uses COMPUTE BY to generate subtotals and COMPUTE to generate a total:SELECT title = CONVERT(char(20), title), type, price, advanceFROM titlesWHERE ytd_sales IS NOT NULL AND type LIKE '%cook%'ORDER BY type DESCCOMPUTE AVG(price), SUM(advance) BY typeCOMPUTE SUM(price), SUM(advance)
--------------------keeping it simple... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-10 : 09:46:26
|
| Also post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|