Re: SQL to add a Totals line

2007-11-07 Thread Stephen Russell
On Nov 7, 2007 1:52 PM, Kenneth Kixmoeller/fh <[EMAIL PROTECTED]> wrote: > > On Nov 6, 2007, at 11:06 AM, Ted Roche wrote: > > > ... but it's a very bad idea. > > PMFJI: Why? You should let your interface do the work for totaling and not back on the server as a second pass. Sometimes you don't ha

Re: SQL to add a Totals line

2007-11-07 Thread Kenneth Kixmoeller/fh
On Nov 7, 2007, at 2:30 PM, Ted Roche wrote: > Not that I haven't tried to get away with > it on occasion, but you need to be wary of the many ways this can bite > you. Oh, yes -- one of those "it seemed like a good idea at the time" deals. Famous (career) last words. Like "I know we can outr

Re: SQL to add a Totals line

2007-11-07 Thread Ted Roche
On 11/7/07, Paul McNett <[EMAIL PROTECTED]> wrote: > > I guess the simplest way to say why it is bad is that you now have a row > with a different meaning from the rest, and we all know that different > meanings really belong in different datasets. > Good explanation. And to expand a bit: it looks

Re: SQL to add a Totals line

2007-11-07 Thread Paul McNett
Kenneth Kixmoeller/fh wrote: > On Nov 7, 2007, at 2:05 PM, Paul McNett wrote: > >> Because it mixes the gathering of the raw data with the processing of >> that data to get meaningful numbers. > > Thanks --- makes sense... Of course, that was just my take. Ted may have his own set of reasons as

Re: SQL to add a Totals line

2007-11-07 Thread Kenneth Kixmoeller/fh
On Nov 7, 2007, at 2:05 PM, Paul McNett wrote: > Because it mixes the gathering of the raw data with the processing of > that data to get meaningful numbers. Thanks --- makes sense... ___ Post Messages to: ProFox@leafe.com Subscription Maintenance: h

Re: SQL to add a Totals line

2007-11-07 Thread Paul Newton
Ken - thank you for asking that question (Why ?) and Paul - thank you for lucid explanation ! Paul Newton Paul McNett wrote: > Kenneth Kixmoeller/fh wrote: > > >> On Nov 6, 2007, at 11:06 AM, Ted Roche wrote: >> >> >>> ... but it's a very bad idea. >>> >> PMFJI: Why? >> > > P

Re: SQL to add a Totals line

2007-11-07 Thread Paul McNett
Kenneth Kixmoeller/fh wrote: > On Nov 6, 2007, at 11:06 AM, Ted Roche wrote: > >> ... but it's a very bad idea. > > PMFJI: Why? PMTFJI: Because it mixes the gathering of the raw data with the processing of that data to get meaningful numbers. What if I issued that SQL, and then inserted a new

Re: SQL to add a Totals line

2007-11-07 Thread Kenneth Kixmoeller/fh
On Nov 6, 2007, at 11:06 AM, Ted Roche wrote: > ... but it's a very bad idea. PMFJI: Why? Ken ___ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/ma

Re: SQL to add a Totals line

2007-11-06 Thread Garrett Fitzgerald
On 11/6/07, Matthew Jarvis <[EMAIL PROTECTED]> wrote: > Has anyone ever come up with a way to have a SQL statement add a line at > the end that consists of totals of all the previous lines? Is something > like that even possible? It's not terribly useful for this case, but I wanted to point out th

Re: SQL to add a Totals line

2007-11-06 Thread Andrew Stirling
Matthew This should do it: CREATE CURSOR 'curinfo' ; ( ; id i ,; namec(20),; Amount n(10,2),; tax n(9,2); ) INSERT INTO 'curinfo' values(4,'Matt',3,.1) INSERT INTO 'curinfo' values(2,'Joe',2,.1) INSERT INTO 'curinfo' values(5,'Tim',6

Re: SQL to add a Totals line

2007-11-06 Thread Stephen Russell
Sure. It's called a Union to bring in the separate query with 'Total' as Name, and dummy values for ID and elsewhere as needed. I have even added an extra col for the grouping and or sorting as needed. I have been faking output like this for years with that trick. Say how is the brewing? __St

Re: SQL to add a Totals line

2007-11-06 Thread Peter Cushing
Ted Roche wrote: > Select cast(ID, char(5)) as ID, Name, Amount, Tax from mytable > UNION > SELECT "Total" as ID, "" as Name, SUM(Amount) as Amount, SUM(Tax) as > Tax) from mytable group by ID > ORDER BY ID > > ... but it's a very bad idea. > > I knew it wasn't possible! Well that's actually tw

Re: SQL to add a Totals line

2007-11-06 Thread Ted Roche
On 11/6/07, Matthew Jarvis <[EMAIL PROTECTED]> wrote: > It would be convenient to have it come out like this: > > ID NameAmount Tax > > 4 Matt3 .10 > 2 Joe 2 .10 > 5 Tim 6 .10 > Total 11 .30 > Select cast(ID, char(5)) as ID

Re: SQL to add a Totals line

2007-11-06 Thread Peter Cushing
Matthew Jarvis wrote: > Has anyone ever come up with a way to have a SQL statement add a line at > the end that consists of totals of all the previous lines? Is something > like that even possible? > > For example, if this would be the result of my SQL code: > > IDNameAmount Tax > > 4

SQL to add a Totals line

2007-11-06 Thread Matthew Jarvis
Has anyone ever come up with a way to have a SQL statement add a line at the end that consists of totals of all the previous lines? Is something like that even possible? For example, if this would be the result of my SQL code: ID NameAmount Tax 4 Matt3 .10 2 Joe