Sagewire Logo

Complex Query - HELP PLEASE

6 Message(s) by 2 Author(s) originally posted in cold fusion


From: salsaevery Date:   Monday, February 12, 2007
OK, here's my problem.
I need to select distinct(membership_number) from the database then
sum(amount) each person's various financial contributions.... then I need to
display these contribution totals in order descending. Sounds simple, and
it should be. But I can not figure it out.

What's the secret? I have tried arrays, lists and query ing a query. I can not
get it to work.

Thanks for your help.
Rob


From: salsaevery Date:   Tuesday, February 13, 2007
Sorry, Microsoft Access Database and Cold Fusion 6.1

I will give your solution a try.... I have not used that formula yet.

wrote in message :
I need to select distinct(membership_number) from the database then
sum(amount) each person's various financial contributions.... then I need
to
display these contribution totals in order descending. Sounds simple,
and
it should be. But I can not figure it out.
It's a little hard to give an answer without knowing the data
schema. Also, what database server are you using?
In Oracle I'd start with something like:
select
membership_number,
sum(amount)
from
table_name
order by
sum(amount) desc
group by
membership_number
--


> Bob Dively | I used to be indecisive, but now I'm not sure...


From: Bob Dively Date:   Tuesday, February 13, 2007
wrote in message:

I need to select distinct(membership_number) from the database then
sum(amount) each person's various financial contributions.... then I need to
display these contribution totals in order descending. Sounds simple, and
it should be. But I can not figure it out.



It's a little hard to give an answer without knowing the data
schema. Also, what database server are you using?

In Oracle I'd start with something like:

select
membership_number,
sum(amount)
from
table_name
order by
sum(amount) desc
group by
membership_number

--
Bob Dively | I used to be indecisive, but now I'm not sure...


From: salsaevery Date:   Tuesday, February 13, 2007
No good.
I can not get rid of this message when I run your query...... I have tried
re-working it too with no luck.

"Syntax error (missing operator) in query expression 'sum(amount) group by
memberid'."

Here's my query statement.
<CFQUERY datasource="#application2.dsn#" name="getinfo">
select sum(amount) memberid
from donations
order by sum(amount)
group by memberid
</CFQUERY>Have any thoughts?

Thanks

wrote in message:
I need to select distinct(membership_number) from the database then
sum(amount) each person's various financial contributions.... then I need
to
display these contribution totals in order descending. Sounds simple,
and
it should be. But I can not figure it out.
It's a little hard to give an answer without knowing the data
schema. Also, what database server are you using?
In Oracle I'd start with something like:
select
membership_number,
sum(amount)
from
table_name
order by
sum(amount) desc
group by
membership_number
--


> Bob Dively | I used to be indecisive, but now I'm not sure...


From: Bob Dively Date:   Tuesday, February 13, 2007
wrote in message:

Here's my query statement.
<CFQUERY datasource="#application2.dsn#" name="getinfo">
select sum(amount) memberid
from donations
order by sum(amount)
group by memberid
</CFQUERY>



Sorry, I got the order by and group by clauses backwards.

Try this (it works, just tested in Access):

SELECT Sum(amount), memberid
FROM donations
GROUP BY memberid
ORDER BY Sum(amount) DESC;

--
Bob Dively | I used to be indecisive, but now I'm not sure...


From: salsaevery Date:   Tuesday, February 13, 2007
Wow, why did not I try that?

That worked perfectly. Exactly what I was hoping for.
Thank you so much for the help.

wrote in message:
Here's my query statement.
<CFQUERY datasource="#application2.dsn#" name="getinfo">
select sum(amount) memberid
from donations
order by sum(amount)
group by memberid
</CFQUERY>
Sorry, I got the order by and group by clauses backwards.
Try this (it works, just tested in Access):
SELECT Sum(amount), memberid
FROM donations
GROUP BY memberid
ORDER BY Sum(amount) DESC;
--


> Bob Dively | I used to be indecisive, but now I'm not sure...



Next Message: CF 7 list box connections


Blogs related to Complex Query - HELP PLEASE

Reiki Healing Love providing Distant Energy Spiritual (Healing ...
Please view this importantDivorceCare is a divorce recovery support group where you ... including update queries, action queries, and the Query Wizards Building forms ... The public Beta 2 of the ColdFusion/Flex Connectivity kit is now ...

How I create an application
The project plan can be simple to complex, but the more effort you put into it, for the simpler ... please add them to the top section with all the cfparams. ... A. Use a sql tool to generate the data, you'll need for each query, ...

Re: Consuming ColdFusion Webservice with .NET
NET and ColdFusion based services? Any > pointers? Yep...if you return a query from your CF based webservice .NET will choke on what's called a QueryBean. Matt Small on-list wrote a DLL for .NET to help it past this issue. ...

What You Need to Know About Web Application Development
An application as complex as the proposed new CGD Web site can only truly be ... the application will need to query numerous different database tables and ... Most languages such as Cold Fusion, PHP and ASP parse the code line by line. ...

Résumé and Cover Letter Secrets Revealed!
The data you assemble will help you write your Guaranteed Résumé (in the ... Please consider my following abilities: • Analyze and solve complex problems. ... FastTrack to ColdFusion training offered by Allaire, New York, NY (2000). ...

Building your first Ajax application with PHP
NB - in making your own functions like this, please note ... This is simply ajax.php, plus the query mark ?, then name=. ... Armed with this knowledge you should now be able to adapt this code to do something maybe a bit more complex. ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional