Re: Need a little sql help...

2011-01-24 Thread Greg Morphis
umns, so I could actually have 20 rows with this >> situation.  They all merge into one though. >> >> Sorry for the confusion, I just redact true data whenever possible. >> >> -Original Message- >> From: Greg Morphis [mailto:gmorp...@gmail.com] >> Sent:

Re: Need a little sql help...

2011-01-24 Thread Dean Lawrence
t: Monday, January 24, 2011 2:00 PM > To: cf-talk > Subject: Re: Need a little sql help... > > > How do you know the 2 Steve's are the same Steve? > What if there was another Steve who was also 40 but lived elsewhere? > Can you provide some more

RE: Need a little sql help...

2011-01-24 Thread DURETTE, STEVEN J (ATTASIAIT)
o: cf-talk Subject: Re: Need a little sql help... How do you know the 2 Steve's are the same Steve? What if there was another Steve who was also 40 but lived elsewhere? Can you provide some more realistic data? And how you'd know they were the sam

Re: Need a little sql help...

2011-01-24 Thread Greg Morphis
How do you know the 2 Steve's are the same Steve? What if there was another Steve who was also 40 but lived elsewhere? Can you provide some more realistic data? And how you'd know they were the same Steve? or whomever? On Mon, Jan 24, 2011 at 12:57 PM, DURETTE, STEVEN J (ATTASIAIT) wrote: > > Hi

Need a little sql help...

2011-01-24 Thread DURETTE, STEVEN J (ATTASIAIT)
Hi all, My SQL mojo seems to have left me. Here is the situation, I have 1 table. In this table there are some times two rows that should have actually been one. Here is an example to explain. Table: Name, Age, address one, address two Row 1: Steve,40,123 Anystreet,NULL Row 2: Steve

Re: (ot) sql help

2010-10-15 Thread Michael J. Sprague
Figured it out. I was missing a join. Should have been: SELECT DISTINCT phases.phase AS phaseLabel, narratives.title, narratives.id, narratives.content, phases.id AS phaseId FROM( ( nsftool.phases2company phases2company

(ot) sql help

2010-10-15 Thread Michael J. Sprague
I am having a SQL problem that I'm guessing amounts to me just being brain dead today but I'd really appreciate any help with this. Here is the query: SELECT phases.phase AS phaseLabel, narratives.title, narratives.id, narratives.content, phases.id AS phaseId FROM

Re: (ot) Transact-SQL Help

2009-09-11 Thread Rick Root
Brad, I'll have to look at your response in much greater detail, but I can tell you this. Currently, I'm running a CF script that populates a prospect_export table once a day. The initial query returns 25,785 rows, which gets flattened into 20,265 rows for reporting purposes. Ultimately I'd rat

RE: (ot) Transact-SQL Help

2009-09-10 Thread Leigh
> As long as you are only dealing with a dozen or so records > from the database it should perform fine and and I think it will be > a heck of a lot simpler than trying to make your SQL server take a > row-based list of  people and pivot them out into columns.  Assuming the example is actually r

RE: (ot) Transact-SQL Help

2009-09-10 Thread brad
> Original Message > Subject: (ot) Transact-SQL Help > From: Rick Root > Date: Thu, September 10, 2009 12:25 pm > To: cf-talk > > > I'm hoping someone here can point me in the right direction. I'm > doing something in CF that I real

Re: (ot) Transact-SQL Help

2009-09-10 Thread Leigh
You might also take a look at ms sql 2005's row_number() function. You may be able to partition the data and use row_number() to limit the returned records. http://msdn.microsoft.com/en-us/library/ms186734.aspx ~

Re: (ot) Transact-SQL Help

2009-09-10 Thread Dave Watts
> This is where the limiting nature of SQL comes in--SQL is a set language > and has no (or very limited) looping/reshaping capability.  Unless MS > has extended their SQL in ways I'm not aware of, this would be nearly > impossible.  That's where the power of CF comes in. That's not true. You can

Re: (ot) Transact-SQL Help

2009-09-10 Thread Ben Conner
Hi Rick, This is where the limiting nature of SQL comes in--SQL is a set language and has no (or very limited) looping/reshaping capability. Unless MS has extended their SQL in ways I'm not aware of, this would be nearly impossible. That's where the power of CF comes in. --Ben Rick Root wrote

(ot) Transact-SQL Help

2009-09-10 Thread Rick Root
I'm hoping someone here can point me in the right direction. I'm doing something in CF that I really need to be doing in SQL: I need to flatten this data: select A.entityid, A.MEMBERID, A.RELTYPE, A.leaderFlag from

Re: SQL Help

2009-08-26 Thread Brian Kotek
Yep, EXISTS will virtually always be faster, usually MUCH faster, than a correlated subquery, because a subquery is evaluated for EVERY ROW processed by the outer query. On Wed, Aug 26, 2009 at 12:43 AM, Mark Henderson wrote: > > Brian Kotek wrote: > > > > WHERE NOT EXISTS should also work. > >

Re: SQL Help

2009-08-25 Thread Mark Henderson
Brian Kotek wrote: > > WHERE NOT EXISTS should also work. > Yes it does, and I knew about that method when using NOT IN, as it was a simple change to my original working query. What I didn't know, but now do after some googling, is that NOT EXISTS means it uses an index in the subquery as opposed

Re: SQL Help

2009-08-25 Thread Brian Kotek
WHERE NOT EXISTS should also work. On Tue, Aug 25, 2009 at 5:27 AM, Mark Henderson wrote: > > Greetings from the chilly south, > > I have this query and it returns the expected result set, but I can't > work out how to use a join instead of the NOT IN clause and I *know* > that is going to be mo

Re: SQL Help

2009-08-25 Thread Mark Henderson
Thanks Billy and Michael (and Kevin). After some trial and error I managed to stumble upon solution (the outer join gave me results but not the expected set). SELECT TOP 1 RV.ID AS Rec_ID ,RV.Date_Viewed ,FS.ID ,FS.Category_ID ,FS.Title ,FS.Comment ,FS.Thumbnail ,FS.Phot

Re: SQL Help

2009-08-25 Thread Billy Cox
Try this: ... FROM tbl_ForSaleCategories C INNER JOIN ( tbl_RecentlyViewed RV INNER JOIN tbl_ForSale FS ON RV.ID = FS.ID ) ON C.ID = FS.Category_ID LEFT JOIN tbl_CoverSpecial CS ON RV.ID = CS.ID WHERE CS.ID IS NULL AND FS.Active = 1 ORDER BY Date_Viewed ASC;

RE: SQL Help

2009-08-25 Thread Dawson, Michael
: Tuesday, August 25, 2009 4:27 AM To: cf-talk Subject: SQL Help Greetings from the chilly south, I have this query and it returns the expected result set, but I can't work out how to use a join instead of the NOT IN clause and I *know* that is going to be more efficient. Basically, I want to exclud

Re: SQL Help

2009-08-25 Thread Kevin Roche
Mark, You might be right but I never got that to work myself, in MSSQL. An experiment you might try is to do that subquery separately in a different CFQUERY then plug in the retrieved value. Occasionally I have found that knid of trick is quicker. Kevin On Tue, Aug 25, 2009 at 11:49 AM, Mark H

Re: SQL Help

2009-08-25 Thread Mark Henderson
Kevin Roche wrote: > > Mark, > > What DBMS are you using? > > If its SQL Server, I don't think what you want to do is possible other than > how you have already done it. If you find another way to do it (with a join) > I would also be interested to see that. > > Kevin Roche > Hi Kevin, Yes it's

Re: SQL Help

2009-08-25 Thread Kevin Roche
Mark, What DBMS are you using? If its SQL Server, I don't think what you want to do is possible other than how you have already done it. If you find another way to do it (with a join) I would also be interested to see that. Kevin Roche ~

SQL Help

2009-08-25 Thread Mark Henderson
Greetings from the chilly south, I have this query and it returns the expected result set, but I can't work out how to use a join instead of the NOT IN clause and I *know* that is going to be more efficient. Basically, I want to exclude the current special from the result set. Any ideas? SE

Re: SQL Help

2009-06-30 Thread Dave Watts
> C'mon, if they are users and they have access to the system, if they go > crazy, > do they really need SQL injection to harm the system ? > They can simply delete all what they have access to, they can replace > content by porn, whatever. > Will CFQURYPARAM protect your application against that

Re: SQL Help

2009-06-30 Thread Claude Schneegans
>>Also, you talk about this like your speaking of only internal applications or applications that could never go on a production environment. Indeed, we were talking about building SQL queries in a variable inside a Content management system. Of course, for parts of the site exposed to public,

RE: SQL Help

2009-06-30 Thread Justin Scott
> If you don't take security in mind when writing > applications it's just a matter of time before > something bad happens. I can't tell you how many times I've been contacted by people who have had their site broken and need an emergency fix. I've made quite a bit of money fixing other people's

RE: SQL Help

2009-06-30 Thread Paul Alkema
27;s just a matter of time before something bad happens. -Original Message- From: Claude Schneegans [mailto:schneeg...@internetique.com] Sent: Tuesday, June 30, 2009 11:19 AM To: cf-talk Subject: Re: SQL Help >>With XSS they can do that while making it look like someone else did it. Probably,

Re: SQL Help

2009-06-30 Thread Claude Schneegans
>>With XSS they can do that while making it look like someone else did it. Probably, but my clients barely know the difference between a computer and a toaster, and I spend more of my time explaining them that in order to "press Ctrl", they must find a key on their keyboard with the letters "C

Re: SQL Help

2009-06-30 Thread James Holmes
With SQL injection they can delete what they don't have access to. With XSS they can do that while making it look like someone else did it. mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ 2009/6/30 Claude Schneegans : > >  >>Internal security problems are far more

Re: SQL Help

2009-06-30 Thread Claude Schneegans
>>Internal security problems are far more common than external ones. Within a large organization, not all users may be trustworthy. C'mon, if they are users and they have access to the system, if they go crazy, do they really need SQL injection to harm the system ? They can simply delete all wh

Re: SQL Help

2009-06-30 Thread James Holmes
Sure, as long as the CMS has no XSS attack points... mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ 2009/6/30 Claude Schneegans : > >  >>And with preserveSingleQuotes() you have to hope you're better at > cleaning input than hackers are at writing SQL injection.

Re: SQL Help

2009-06-30 Thread Dave Watts
> When I'm talking about a CMS, I'm talking about some tool some customers > have paid for and that is only accessible by approved users with > authentication. > Now if they want to hack and sabotage their own application they have > paid for, it's their problem, and if it ever happens, they will

RE: SQL Help

2009-06-30 Thread Paul Alkema
would just use a stored proc and feed in the name. -Original Message- From: Scott Brady [mailto:dsbr...@gmail.com] Sent: Tuesday, June 30, 2009 9:52 AM To: cf-talk Subject: Re: SQL Help There's no reason you need a variable to do multiple updates in a single query statement. You can

Re: SQL Help

2009-06-30 Thread Scott Brady
There's no reason you need a variable to do multiple updates in a single query statement. You can still put the SQL inside the query tags and, as you say, separate the statements with a semi-colon. Scott On Tue, Jun 30, 2009 at 6:55 AM, Stephane Vantroyen wrote: > > I don't agree with that : som

Re: SQL Help

2009-06-30 Thread Claude Schneegans
>>And with preserveSingleQuotes() you have to hope you're better at cleaning input than hackers are at writing SQL injection. When I'm talking about a CMS, I'm talking about some tool some customers have paid for and that is only accessible by approved users with authentication. Now if they wan

RE: SQL Help

2009-06-30 Thread Paul Alkema
phane Vantroyen [mailto:s...@emakina.com] Sent: Tuesday, June 30, 2009 8:55 AM To: cf-talk Subject: Re: SQL Help "it's not good practice in ColdFusion to do this. " I don't agree with that : sometimes you have to do multiple updates, inserts or else at the same time, depending

Re: SQL Help

2009-06-30 Thread James Holmes
And with preserveSingleQuotes() you have to hope you're better at cleaning input than hackers are at writing SQL injection. And yes, we all know you're totally awesome at it; this response is for others who'd rather not make that bet. mxAjax / CFAjax docs and other useful articles: http://www.bif

Re: SQL Help

2009-06-30 Thread Claude Schneegans
>>As Dominic said, putting the entire sql statement in as a variable in ColdFusion isn't necessary. Please, there IS a very good reason one would put an SQL statement in a variable: when using some tool to generate build queries for instance. I have many examples in my own CMS, like a report bu

Re: SQL Help

2009-06-30 Thread Stephane Vantroyen
"it's not good practice in ColdFusion to do this. " I don't agree with that : sometimes you have to do multiple updates, inserts or else at the same time, depending on your process and some conditions; instead of doing multiple (and thus multiple db connections), it is sometimes cool to be a

RE: SQL Help

2009-06-30 Thread Paul Alkema
#replace(sqlToRun,"''","'","ALL")# Paul Alkema -Original Message- From: Dominic Watson [mailto:watson.domi...@googlemail.com] Sent: Tuesday, June 30, 2009 5:22 AM To: cf-talk Subject: Re: SQL Help Basically, the is kind of redundant a

Re: SQL Help

2009-06-30 Thread Dominic Watson
Basically, the is kind of redundant and negates the benefit of the cfquery tag. Put all you SQL inside the cfquery tag. cfqueryparam is only valid within cfquery tags. Dominic 2009/6/28 Jason Slack : > > CF 8.01 OS X. > > I have: > > > >         #sqlToRun# > >         >           #sqlToRun# >

Re: SQL Help

2009-06-28 Thread Matt Quackenbush
A) Always use . (Note the period.) B) When in doubt, use anyways. (Note the period.) C) While preserveSingleQuotes() can be a useful tool at times, I would have a very difficult time thinking of a time where I would use it. D) Always use . (Note again, the period.) E) You cannot use in the mi

Re: SQL Help

2009-06-28 Thread Jason Slack
Right I am switching everything to as I read about SQL injection. Do you see my Invalid CFML construct found on line 22 at column 120. above though? I still dont. -Jason >if you're going to be generating your SQL like that, you'll need to wrap >your final variable in preserveSingleQuotes().

Re: SQL Help

2009-06-28 Thread Charlie Griefer
if you're going to be generating your SQL like that, you'll need to wrap your final variable in preserveSingleQuotes(). so... #preserveSingleQuotes(sqlToRun)# it will be pointed out to you (possibly before I even finish composing this response), that you are leaving yourself open to SQL

SQL Help

2009-06-28 Thread Jason Slack
CF 8.01 OS X. I have: #sqlToRun# #sqlToRun# the is: INSERT INTO personalevent(eventid, userid, username, eventdate) VALUES(1, 1, 'jason', '2009-06-27') Which runs fine in a SQL Editor, but running that in the above I get:

Re: SQL help..

2008-10-29 Thread cf coder
I'm really greatful to you for the post. >Just answered this on the SQL list: >http://www.houseoffusion.com/groups/sql/thread.cfm/threadid:855 ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date

Re: SQL help..

2008-10-29 Thread Peter Boughton
Just answered this on the SQL list: http://www.houseoffusion.com/groups/sql/thread.cfm/threadid:855 ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick

SQL help..

2008-10-29 Thread cf coder
Hello there, I do appreciate this isn't the right forum for posting this question but I have posted my question in the SQL forum but I haven't heard anything back. It's a very straightforward query... at least I hope it is for someone with good sql skills. I was hoping someone could help here.

Re: SQL Help

2008-09-16 Thread C S
> It also begs the question, if they were only supposed to have one > entry > per e-mail address, why wasn't there error checking or a constraint on > > the table to force this in the first place? True enough. I was thinking the same thing myself ;-) ~

Re: SQL Help

2008-09-16 Thread Justin Scott
> The records are from contest entries. People can only enter with one email > address. Some people entered multiple times, using the same email address. So, why all the complexity with joins and subqueries? Just... SELECT DISTINCT email FROM sometable then pick a winner from the list of

Re: SQL Help

2008-09-16 Thread Jeff F
The records are from contest entries. People can only enter with one email address. Some people entered multiple times, using the same email address. I need to get a record set used to pick a winner, including just one of the records from the duplicate email entries. ~

Re: SQL Help

2008-09-16 Thread C S
> I need to get a record set used to pick a winner, including just one > of the records from the duplicate email entries. If it does not matter which one, try the query I posted in my first response. The syntax is not tested, but it has the right concept. ~

Re: SQL Help

2008-09-16 Thread Jeff F
The records are from contest entries. People can only enter with one email address. Some people entered multiple times, using the same email address. I need to get a record set used to pick a winner, including just one of the records from the duplicate email entries. ~

Re: SQL Help

2008-09-16 Thread C S
> You could try something like this. Not tested, but the idea is to > select a single PK for each email. Then use a JOIN to display the > details for those PK's. Note, the previous query assumes it does not matter which record is returned.

Re: SQL Help

2008-09-16 Thread C S
> When there are records with duplicate > emails addresses, I need to include one of them. So you are trying to display one record for each email address? You could try something like this. Not tested, but the idea is to select a single PK for each email. Then use a JOIN to display the detail

Re: SQL Help

2008-09-16 Thread Judah McAuley
Are the other fields in your table the same when the email is the same? Meaning, are the records really duplicate? Or is it just the email that is duplicate and the other fields may have varying values for two rows that have the same email? If they do vary, do you care which of the "duplicate" rows

Re: SQL Help

2008-09-16 Thread Jeff F
Thanks Jim. Now I see. I guess what I'm looking for would be something like this then: SELECT mytable.lastname,mytable.email FROM mytable GROUP BY mytable.email HAVING distinct(mytable.email) Which of course does not work. When there are records with duplicate emails addresses, I need t

Re: SQL Help

2008-09-16 Thread Jim Wright
On Tue, Sep 16, 2008 at 10:13 AM, Jeff F <[EMAIL PROTECTED]> wrote: > SELECT distinct mytable.email > FROM mytable > I get 19588 as a recordcount. This number would include email addresses that are duplicated in the table (but only a count of 1 for each distinct address). >SELECT mytable.

Re: SQL Help

2008-09-16 Thread Jeff F
Jim, At first glance that seems to work, however the recordcounts appear to be off. What I did was a simple query to find the total number of distinct email addresses: SELECT distinct mytable.email FROM mytable I get 19588 as a recordcount. When I run SELECT mytable.lastname,

RE: SQL Help

2008-09-16 Thread Rick Faircloth
= '#select_distinct_email.email#' #lastname# #firstname# #city# #state# > -Original Message- > From: Rick Faircloth [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 16, 2008 9:42 AM > To: CF-Talk > Subj

Re: SQL Help

2008-09-16 Thread Jim Wright
On Tue, Sep 16, 2008 at 8:58 AM, Jeff F <[EMAIL PROTECTED]> wrote: > I've got a table (MySQL) with about 20k records. I'd like to be able to get > all fields from the table with distinct email addresses. Essentially, I'm > weeding out records with duplicate email addresses. > > What I'm trying do

RE: SQL Help

2008-09-16 Thread Rick Faircloth
; Sent: Tuesday, September 16, 2008 8:58 AM > To: CF-Talk > Subject: SQL Help > > I've got a table (MySQL) with about 20k records. I'd like to be able to get > all fields from the table > with distinct email addresses. Essentially, I'm weeding out records with &

Re: SQL Help

2008-09-16 Thread Gert Franz
Assuming your PK is named customerID you can do the following: SELECT mytable.lastname, mytable.firstname, mytable.city, mytable.state FROM mytable WHERE mytable.customerID in (select min(customerID) from mytable group by email) There is at least one problem in your query. The in () statement is

SQL Help

2008-09-16 Thread Jeff F
I've got a table (MySQL) with about 20k records. I'd like to be able to get all fields from the table with distinct email addresses. Essentially, I'm weeding out records with duplicate email addresses. What I'm trying does not work: SELECT mytable.lastname, mytable.firstname, mytable.city, my

Re: sql help <> NEQ

2008-04-03 Thread Paul Ihrig
ok i go it i think but it just looks so weird to me.. it looks back wards but works... SELECT DISTINCT TOP 100 PERCENT dbo.V_riprod_ZMATMAST.sap_partnum AS NEQnumb FROM dbo.V_riprod_ZMATMAST LEFT OUTER JOIN dbo.V_riprod_Specs_ZMATMAST_EQ ON dbo.V_riprod_ZMATMAST.sap_

sql help <> NEQ

2008-04-02 Thread Paul Ihrig
ok i have 2 views V_riprod_ZMATMAST returns 60 records V_riprod_Specs_ZMATMAST_EQ returns 39 records or so that are matched in another table. these i will do an update on problem i am having is the NEQ <> i am trying to use the view below to return all the results of the records that don't match.

Re: sql help!!!!!!!!!!

2007-11-23 Thread Dave l
upsell_sort > FROM products, brands, upsell > WHERE products.brand_id = brands.brand_id > AND products.product_id = upsell.product_id > AND products.product_id in (20,21) > ORDER BY upsell.upsell_sort ASC, > brands.brand_name ASC, > products.product_item ASC > > And what&

Re: sql help!!!!!!!!!!

2007-11-23 Thread Will Tomlinson
d_id AND products.product_id = upsell.product_id AND products.product_id in (20,21) ORDER BY upsell.upsell_sort ASC, brands.brand_name ASC, products.product_item ASC And what's with the... sql help!! Sounds like you're goin' down o

sql help!!!!!!!!!!

2007-11-23 Thread Dave l
ok i need to put Upsell items underneath the "add upsell items" form, so that they can see what upsell products they currently have for that product. (mysql 5 btw) So it is all good but then they asked for me to make it "sort-able" and that is causing me a headache and can't quite get that last

OT: SQL Help

2007-10-24 Thread Rick Root
I'm having a weird query issue with SQL server... The following query inserts two rows into the query_results table: insert into ENQUIRE.dbo.QUERY_RESULTS ( QUERYID, ENTITY_ID ) SELECT DISTINCT 1933 AS QUERYID, A.ENTITY_ID FROM BIOTAB1

Re: SQL Help, please ...

2007-06-27 Thread Jochem van Dieten
[EMAIL PROTECTED] wrote: > HostName, iDate, Package > client1, 2007-06-01, Update1 > client1, 2007-06-01, Update2 > client1, 2007-06-01, Update3 > client1, 2007-06-02, Update5 > client1, 2007-06-02, NewApp > client2, 2007-06-01, Update1 > client2, 2007-06-01, Update2 > client2, 2007-06-01, Update3

RE: SQL Help, please ...

2007-06-27 Thread Brad Wood
only. (syntax depends on your DB). ~Brad -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 26, 2007 10:16 PM To: CF-Talk Subject: SQL Help, please ... Hello, It's been a wile since I have had to do much in the way of SQL queries and I need

SQL Help, please ...

2007-06-26 Thread tjones
Hello, It's been a wile since I have had to do much in the way of SQL queries and I need some help. I have a table called "installs" that looks like this HostName, iDate, Package client1, 2007-06-01, Update1 client1, 2007-06-01, Update2 client1, 2007-06-01, Update3 client1, 2007-06-02, Update5 cl

ANYONE? Pretty please?? more SQL help....

2007-04-17 Thread Will Tomlinson
Heck, I did up a special page just to explain my needs better. :) http://wtomlinson.com/eval.html been flailing away at this for quite a while now... Thanks, Will ~| ColdFusion MX7 and Flex 2 Build sales & marketing dashboard

Need more SQL help....

2007-04-16 Thread Will Tomlinson
Ok, I have one last query to get right in my eval app. Here's my schema: http://wtomlinson.com/evalschema.gif Jim has been kind enough to help work out my queries. Now, I just need to rollup my rankings questions and I'm done (mostly). The data looks like this: tblquestions: Rank these tools

Re: SQL Help - Answered

2007-04-04 Thread [EMAIL PROTECTED]
IL PROTECTED]> > To: "CF-Talk" > Sent: Tuesday, April 03, 2007 2:09 PM > Subject: Re: SQL Help - Answered > > > >> I'm going to have to look at something. I'm still not getting what I >> anticipated. >> >> There are over 3700

Re: SQL Help - Answered

2007-04-03 Thread Josh Nathanson
Dump that and see if you're any closer to what you want. -- Josh - Original Message - From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Tuesday, April 03, 2007 2:09 PM Subject: Re: SQL Help - Answered > I'm going to have to look

Re: SQL Help - Answered

2007-04-03 Thread Greg Morphis
can you provide a sample of your data and the way your table is designed (column name, type)? Thanks On 4/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm going to have to look at something. I'm still not getting what I > anticipated. > > There are over 3700 records of which 1775 of them

Re: SQL Help - Answered

2007-04-03 Thread [EMAIL PROTECTED]
I'm going to have to look at something. I'm still not getting what I anticipated. There are over 3700 records of which 1775 of them are distinct values for "RATE". However, I am only getting values of 1 for COUNT(DISTINCT rate) as rateCount. I was trying to find out how many records are the

Re: SQL Help - Answered

2007-04-03 Thread Greg Morphis
No problem, if you want to know "why" take a look at aggregate functions, which is what "count" is, as well as others.. On 4/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Thank you > > Greg Morphis wrote: > > You need a group by in your query.. > > > >> SELECT count(DISTINCT rate) as rate

Re: SQL Help - Answered

2007-04-03 Thread [EMAIL PROTECTED]
Thank you Greg Morphis wrote: > You need a group by in your query.. > >> SELECT count(DISTINCT rate) as rateCount, rate >> FROMmyrates >> WHERE my_code = 385 and year = 2005 >> > GROUP BY rate > >> ORDER BY rate >> > > > > > On 4/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> w

Re: SQL Help

2007-04-03 Thread Greg Morphis
You need a group by in your query.. > SELECT count(DISTINCT rate) as rateCount, rate > FROMmyrates > WHERE my_code = 385 and year = 2005 GROUP BY rate > ORDER BY rate On 4/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Why do the first two queries work and the last one fail? The on

SQL Help

2007-04-03 Thread [EMAIL PROTECTED]
Why do the first two queries work and the last one fail? The only difference is adding the comma and additional field to the SELECT statement. SELECT count(DISTINCT rate) as rateCount FROMmyrates WHERE my_code = 385 and year = 2005 ORDER BY rate SELECT rate FROMmyrates WHERE my_

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-21 Thread Will Tomlinson
Ok Jim, this is getting the results I'm after. The counts are correct, everything looks right so far. I just needta test it some more. Would you please email me offlist? WT at WTOMLINSON.com Thanks a ton dude! Will ~| Co

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-21 Thread Will Tomlinson
Thanks a ton Jim! I'll give it a shot later today and let you know the results. Thanks! Will ~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & Flex 2 Free Trial http://www.adobe.com/products/coldf

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-21 Thread Jim Wright
Three things I noted... 1. There are a lot of duplicated columns in the result list...I removed those to make it easier to read and debug 2. It looks to me like tblevalanswerresults needs to be joined to both tblquestions and tblanswers...see below 3. When you join on tblEvaluations like you did

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-21 Thread Will Tomlinson
>No been following this thread, but can you do the first two parts? Yes, I've got this part working with Jochem's fine SQL. > >What about the third part? > >"With each possible answer, show me a count of the ones that were selected" Nope > >Do those then try to combine them. > >Adrian This is

RE: Need More SQL help - DRIVING ME NUTS!

2007-03-21 Thread Adrian Lynch
try to combine them. Adrian -Original Message- From: Will Tomlinson [mailto:[EMAIL PROTECTED] Sent: 21 March 2007 10:45 To: CF-Talk Subject: Re: Need More SQL help - DRIVING ME NUTS! Put every field from the select that is not an aggregate in your >group by and you get something un

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-21 Thread Will Tomlinson
Put every field from the select that is not an aggregate in your >group by and you get something understandable. > >Jochem Jochem, I did this and it still gives me incorrect results. It gives me a count of 1 for each answer, no matter what the answer is. I'm just testing with one evaluation r

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-20 Thread Jochem van Dieten
Will Tomlinson wrote: > And what I can't figure out is why this: > > COUNT(EAR.answerID) AS numAnswers > > would produce values of 1 for rows in which it should be 0. Because you are using MySQL and MySQL has broken grouping. Your statement is invalid SQL and the database should throw an er

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-20 Thread Will Tomlinson
And what I can't figure out is why this: COUNT(EAR.answerID) AS numAnswers would produce values of 1 for rows in which it should be 0. Thanks, Will ~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-20 Thread Will Tomlinson
MySQL 5 Here's some table date as it looks in tblEvalAnswerResults. This is a many table. http://wtomlinson.com/evalQRYs/tableData.gif Then here's what my query produces. I had to add E.evalID to get both evaluations to show up in the results. I went ahead and did another evaluation, so ther

Re: Need More SQL help - DRIVING ME NUTS!

2007-03-20 Thread Qasim Rasheed
Will, Which DB are you using and if it's not difficult can you also post db scripts to create tables and populate some sample data.? Thanks Qasim On 3/20/07, Will Tomlinson <[EMAIL PROTECTED]> wrote: > > Ok, I'm really close on this. I've been workin on it for hours, changing > queries, not ge

Need More SQL help - DRIVING ME NUTS!

2007-03-20 Thread Will Tomlinson
Ok, I'm really close on this. I've been workin on it for hours, changing queries, not gettin the results I need. I filled out one survey of 3 questions, each question has 5 possible answers. Here's the query: SELECT Q.questionID, Q.questionsetID, Q.question, Q.answersetid, ARS.answersetid,

Re: Need some SQL help!

2007-03-20 Thread Will Tomlinson
Ok, I ALMOST got it! The results that are incorrect is just the number of answers per question. Here's what the query returns: http://wtomlinson.com/evalQRYs/qryData.jpg Look at numAnswers. I completed two evaluations. But numAnswers should be the total count of each answer that was given. I

Re: Need some SQL help!

2007-03-20 Thread Will Tomlinson
I may have figured it out... I used this for my group by. GROUP BY Q.questionID, A.answerID Still needta test it more tho but my results are lookin better. Thanks Jochem! Will ~| ColdFusion MX7 and Flex 2 Build sales & mar

Re: Need some SQL help!

2007-03-20 Thread Will Tomlinson
Jochem, this is close but not quite giving me the results I'm after. Here's the data as it looks in the table. I answered three questions, each had a choice of 5 answers. I chose 1 answer for each question. Here's the data as it appears in the tblEvalAnswerResults many table. http://wtomlinso

Re: Need some SQL help!

2007-03-20 Thread Will Tomlinson
>Will Tomlinson wrote: >> >> Do all these individual queries go into one query, separated with a ; ? > >Just run the last one, the others are to show how you build it step by step. > duhh.. :) Thanks Jochem! Will ~| ColdFu

Re: Need some SQL help!

2007-03-20 Thread Jochem van Dieten
Will Tomlinson wrote: > > Do all these individual queries go into one query, separated with a ; ? Just run the last one, the others are to show how you build it step by step. Jochem ~| Upgrade to Adobe ColdFusion MX7 Experience

  1   2   3   4   5   >