POV-Ray : Newsgroups : povray.off-topic : SQL question : Re: SQL question Server Time
29 Sep 2024 15:26:33 EDT (-0400)
  Re: SQL question  
From: Invisible
Date: 11 Mar 2009 05:43:30
Message: <49b787c2$1@news.povray.org>
>> I don't have an SQL engine in front of me, but I would have expected
>>
>>   SELECT ExpID, COUNT(*) FROM Table WHERE EventID=1 GUOP BY ExpID;
> 
> I think I tried that and got back something like:
> 
> ExpID Count
> 1     1
> 2     1

Mmm, OK. I'm a little rusty with this stuff. It's been a while. ;-)

> BTW does it matter if I drop the ExpID after the SELECT, I'm not 
> interested in any experimentID, just the count of them that have an ID=1 
> event.

OK, what *precisely* are you trying to count?

1. The number of times event X occurred in each experiment?

2. The number of experiments where event X occurred at least once?

If there's one thing you quickly learn about SQL, it's that you need to 
have a very clear picture in your brain of exactly what you're answer 
you're trying to get. And if you ask people for help, you need to be 
very careful about explaining to them what you're after. ;-)

>>   SELECT ExpID, COUNT(*) / Total
>>   FROM Table, (SELECT COUNT(*) as Total FROM Table2)
>>   GOUP BY ExpID;
> 
> Oh ok cool, will experiment with that sort of syntax.

That or something like that ought to do it, I believe.

> The reason I want it all in one SQL function is that I'm thinking of 
> making some external text-based file that lists all the possible queries 
> people might want to run on the data, so then I can 
> change the queries without modifying the actual code.

Makes sense.

> Someone has probably already invented a much better way 
> to do this sort of thing, but hey this is my first database app!

Well, you could always store the SQL in the database itself! ;-)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.