28 May 2007

Nesting the SQL COUNT() function in MAX(COUNT())



I am trying to run this query and I get an error:

SQL> select
2 * from member m
3 where m.username IN (select fg.username from filmography fg,
4 (select f.username,max(count(awards)) from filmography f
5 group by username,awards
6 having max(count(awards))
7 >0));
having max(count(awards))
ERROR at line 6:
ORA-00935: group function is nested too deeply

Please help me.


Okay, the error message is saying that you cannot nest functions like that.

It looks like all you want is the member with the most awards. Here's how I would do this in Oracle:

select username
, othercolumns
from member
where username in
( select username
from ( select username
from filmography
by username
by count(awards) desc
) as t
where rownum = 1

WHERE ROWNUM=1 is used to obtain the row which has the largest COUNT(AWARDS) in the innermost subquery.

I have seen many people struggled with this type of question at university now I have found a solution that works.

10 May 2007

New ftp / mirror site every one should have a look at

I just found this site while looking for local South African resources for open source distro's, and other open source product. This has to be one of the best sites that I have found ever. It has mirrors for Ubuntu, fedora, bsd, gentoo and a whole lot more. TENET Tertiary Education Network http://mirror.ac.za/

One of the best parts of this site is the local link to the MIT open course ware site. http://ocw.mirror.ac.za/. A brilliant place to read up on just about any thing from rocket science to management and psychology.
I will definitely be using this site a lot in the future.

here is a list of the links available
Mirror Description:
MIT Open Courseware
Course materials for a wide range of topics
PHP.NET Mirror
PHP is a server side scripting language for web devlopment
ProFTPD Mirror
Is a GNU open source mirror of the Pro FTP project which is ftp server software.
Mozilla Mirror
Blastwave Solaris FreewareMirror
GENTOO Linux Mirror
FreeBSD Mirror
Knoppix Linux
Ubuntu Mirror
Centos Mirror
Debian Mirror
Slackware Mirror
bio-mirror.net Mirror
Is a mirror of a database containing genetics research
OpenOffice Mirror
MySQL Mirror
CPAN Mirror
Comprehensive Perl archive network is a major resource for Perl programmers.
Fedora MirrorCTAN Mirror
Is a TEX mirror, TEX is a language / tool set for formating and structuring text for publishing web development and so on,
www.honeynet.org Mirror
Is a site focused on network security, they have a large library of network security related information.
Scientific Linux Mirror

9 May 2007

how to load a file in xspim

I am tutoring a class that teaches basic assembler using the mips architecture and spim. Im using linux so i got the source and compiled and installed it. I then began buy running xspim. What a pain no documentation enplaning any thing that I could make sense of. So here I am writing about how I got it to work.

This is how to load an assembler file and make sense of the first screen you see when you first run xspim.
start xspim buy typeing
#> xspim
at the comand line. or buy running it from the /usr/local/bin/xspim
#> /usr/local/bin/xspim
depending on your configuration.

The following window pops up.

The assembler you can see in the text segment part of the window doesn't run and out puts an error sayin
Instruction references undefined symbol at 0x00400014
jal 0x00000000 [main].
This code that is already loaded comes from the /usr/local/lib/exceptions.s file. It is the assembler code to load and run your file.

You can load your file buy clicking the load button in the middle part of the window. This is will open the following pop window.Input the file location relative to the root (/) directory ie as /home/#user/mips/my_file

click the assembly file button. You will see that the jal xxxxxxxx [main] command changes to reference your code at memory location xxxxxxxxx. which will be just after the load program code.
the jal xxxxxxxx [main] instruction is a jump and load instruction with the memory address and label [main] being the label. So you need to have a lable in your source code that contains a main label.
my_file looks like this
main: addi $v0, $0, 5 # read into $t1
add $t1, $0, $v0
addi $t1, $t1, -32 # F -32
addi $t2, $0, 5
mult $t1, $t2 # (F -32) * 5 (mult before div)
mflo $t1
addi $t2, $0, 9
div $t1, $t2 # (F -32) * 5/9
mflo $t1
addi $v0, $0, 1 # print $t1
add $a0, $0, $t1
addi $v0, $0, 10 # exit

what's important here is th "main:" part of the code which will be where the jal xxxxxxxx [main] will jump to when running your assembler. Now you can step through your code and run it buy clicking the relevant buttons. You will notice that their args parameter references your mips file. You will need to edit your mips assembler file with an other program like gedit, or scite.

It took me a while to figure out how all this worked as the documentation dose not have a quick start tutorial or any thing like that. I hope this will be use full for some assembler hackers out there.