Print Page | Close Window

Dividing in SQL

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7609
Printed Date: 30 March 2026 at 8:41am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Dividing in SQL
Posted By: mamorley
Subject: Dividing in SQL
Date Posted: 25 November 2003 at 4:49pm

I have the following query and am not having success getting it to run.  Can anyone help me troubleshoot?  Essentially I am trying to divide the first count by the second.

 

select count (*)
       from R5events
          where evt_completed <=   evt_target
          and evt_rstatus = 'C'
          and evt_person = 'MORLEY-MP'
/
select count (*)
       from R5events
          where evt_person = 'MORLEY-MP'

 

Thanks




Replies:
Posted By: michael
Date Posted: 26 November 2003 at 9:36am
Select
(
select count (*)
       from R5events
          where evt_completed <=   evt_target
          and evt_rstatus = 'C'
          and evt_person = 'MORLEY-MP'
)
/
(
select count (*)
       from R5events
          where evt_person = 'MORLEY-MP'
)
as mydivision

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: mamorley
Date Posted: 26 November 2003 at 2:11pm
Thanks Michael, but getting an error stating FROM keyword not found where expected....


Posted By: michael
Date Posted: 26 November 2003 at 2:57pm
Seems you are using access or so which always had problems doing subqueries. I am not sure how to do it with something like access, actually gave it a quick try but does not like any of the solutions I offered. Anyway, maybe someone else here knows access a little better.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: mamorley
Date Posted: 26 November 2003 at 3:22pm

Thanks for your help Michael...

I am actually using sql to query an oracle database...



Posted By: theSCIENTIST
Date Posted: 29 November 2003 at 2:07am

If using Access it might need the AS after the count (FROM R5events AS myCount).

Hope it solves it.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net