MyG37.com | G35Driver.com | My350Z.com | ZDriver.com
 
Show Your Support Become A Premier Member



Go Back   G35Driver > The Lounge OT > The Lounge (Off Topic)
New! Use your Facebook, Google, AIM & Yahoo accounts to securely log into this site, click logo to login  

Welcome to G35Driver.com!
Welcome to G35Driver.com.

You are currently viewing our forum as a guest, which gives you limited access to view most discussions and access our other features. By joining our community, at no cost, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is free, fast and simple, join G35Driver.com community today!


Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-16-2009, 02:33 PM
Registered User
2003 Infiniti G35
 
Join Date: Mar 2009
Location: Torrance, CA
Posts: 1,341
iTrader: (2)
SQL help....

Can anyone tell me why this wouldn't work? (I left out the rest, it's getting an Invalid number of arguments error)
Code:
select pvid,count(distinct ptid,d_visit)
If this is fine for Oracle 9i, I will post up the rest of the query. Just want to keep things simple.
__________________
03 BS Coupe 6MT, Inven, there's not enough spaces here...
Reply With Quote
  #2  
Old 11-17-2009, 12:23 AM
Registered User
2005 BMW M3
 
Join Date: Jun 2006
Location: Durham, NC
Posts: 767
iTrader: (0)
Not sure about Oracle, but it works fine in mysql as long as you group the results by one of those columns.
__________________
2005 BMW M3 Coupe 6MT<<>> '97 Triumph 900
Reply With Quote
  #3  
Old 11-17-2009, 02:41 PM
Registered User
2003 Infiniti G35
 
Join Date: Mar 2009
Location: Torrance, CA
Posts: 1,341
iTrader: (2)
It works for my MySQL too. Oracle 9i is pretty ancient. fvckin sh!t

I know I can run a subquery like
Code:
select distinct ptid,d_visit from blah blah blag
How can I count() a subquery?
__________________
03 BS Coupe 6MT, Inven, there's not enough spaces here...
Reply With Quote
  #4  
Old 11-17-2009, 06:25 PM
kernel's Avatar
Super Moderator
 
Join Date: Jun 2007
Posts: 8,895
iTrader: (2)
what you wrote in your first one honestly doesn't make any sense....I think what you need is:

SELECT PVID, COUNT(*)

FROM (
SELECT DISTINCT PVID, D_VISIT
FROM TBL A) B

GROUP BY PVID
__________________
Reply With Quote
  #5  
Old 11-18-2009, 11:49 AM
Registered User
2003 Infiniti G35
 
Join Date: Mar 2009
Location: Torrance, CA
Posts: 1,341
iTrader: (2)
That query doesn't work Kernel.
count(distinct ptid,d_visit) is exactly what I need, but it seems Oracle 9i is too old or something.
__________________
03 BS Coupe 6MT, Inven, there's not enough spaces here...
Reply With Quote
  #6  
Old 11-18-2009, 06:05 PM
kernel's Avatar
Super Moderator
 
Join Date: Jun 2007
Posts: 8,895
iTrader: (2)
by doesn't work, you mean won't run (in which case, what's the error?) or doesn't give you what you want?

Are you wanting a count of the unique ptid and d_visits? If not, write out what you want in english instead of SQL and i'll see if I can help.

If you do want a count of the unique ptid and d_visits, then you just need this:
SELECT COUNT(*)

FROM (
SELECT DISTINCT PVID, D_VISIT
FROM TBL A) B
__________________
Reply With Quote
  #7  
Old 11-18-2009, 06:56 PM
Registered User
2003 Infiniti G35
 
Join Date: Mar 2009
Location: Torrance, CA
Posts: 1,341
iTrader: (2)
How do I do a count of distinct ptid,d_visit per each distinct pvid? And displaying like 'SELECT PVID,COUNT(*)"
__________________
03 BS Coupe 6MT, Inven, there's not enough spaces here...
Reply With Quote
  #8  
Old 11-19-2009, 09:47 PM
kernel's Avatar
Super Moderator
 
Join Date: Jun 2007
Posts: 8,895
iTrader: (2)
oh, sorry, didn't notice there is a pvid and a ptid.

it's hard to do it without seeing the data, but can you not just do a distinct pvid, ptid, d_visit and then a count of that? Basically add ptid into the last subquery I have above?
__________________
Reply With Quote
  #9  
Old 11-20-2009, 12:29 PM
Registered User
2003 Infiniti G35
 
Join Date: Mar 2009
Location: Torrance, CA
Posts: 1,341
iTrader: (2)
I think I should just extract the data, and then import it into my MySQL db so that the original query would work. I hope we upgrade to 10g
Using PHP to automate the process.
__________________
03 BS Coupe 6MT, Inven, there's not enough spaces here...

Last edited by pythonjosh; 11-20-2009 at 12:53 PM.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -4. The time now is 07:25 AM.

G35Driver - Archive - Top

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright ©2002 - 2008, G35DRIVER.COM All Rights Reserved.
Advertising - Terms of Service - Privacy Policy - JOBS


MyG37.com | My350Z.com | ZDriver.com | G35Driver.com