On Sun, Nov 15, 2009 at 12:34 PM, Peter Haworth <p...@mollysrevenge.com> wrote:
> Interesting you should classify my data need as a waste without
> knowing anything about my application.  What if I want to calculate a
> percentage that the first column is of the total - would it still be a
> waste to calculate the total?

I was not casting aspersions on you, but merely commenting on the
technique without knowing any other context. Perhaps you should have
provided more context for your query in the first place.

You are correct.. if you want to calculate the percentage that the
first col is of the total, then you would need to know the total.

Kees and Igor have already responded to you on how to do that.

>
> As far as I'm concerned , the more data manipulation that can be done
> by the underlying db system, the better.  That way my application is
> protected from database structure changes. Subject to performance
> considerations of course.  Isn't that one of the purposes of db systems?
>

Well, yes and no. At its purest, a database stores data with a great
amount of integrity and returns it back to you as quickly as it can.
Rest of the shenanigans are developed in the application that uses
that db. Lines begin to blur, and sometimes you have entire
applications inside a database, and sometimes you have entire
databases inside applications. You are the only one who can choose the
most appropriate strategy for yourself.

A better way, usually, would be to do in the db what the db can do
quickly, then do everything else in the application. As I said above,
Igor showed you how you could return a result set with varying
conditional values in one column, and a sum total of those values in
the other column. You can try that.



> Pete Haworth
>
>
> On Nov 15, 2009, at 4:00 AM, sqlite-users-requ...@sqlite.org wrote:
>
>> Think about what you are asking for... your result set is going to
>> contain two columns. The first column will have different values for
>> every row, but the second column will have the same value in every
>> row. Something like so...
>>
>> 5  33
>> 3  33
>> 7  33
>> 4  33
>> 9  33
>> 5  33
>>
>> and so on. What a waste. Still, if you insist on something like that,
>> do it in your application. Else, run two separate queries and union
>> them as Kees showed you.
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
Sent from Madison, Wisconsin, United States
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to