Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

SQLplus

Name: How to count 0 2008-10-29 19:53

I'm trying to count the number of 'classes' each student is taking, but I'm supposed to report back 0 if there are none. Right now, it just doesn't respond with the student.
Anyone out there been through a database class who solved this?

Name: Anonymous 2008-10-29 19:57

Drill down and chop that shit up bro.

Name: Anonymous 2008-10-29 19:58

.. UNION SELECT student_id, 0 AS n_classes FROM students

Name: Anonymous 2008-10-29 20:13

Uhm:
select count(sid)
from studentclasses
where sid = 123456;

That returns 0 if student id 123456 doesn't exist. What's the problem?

Name: How to count 0 2008-10-29 20:18

select student.student_id, student_name, count(student.student_id)
from student, enrolls
where student.student_id=enrolls.student_id
group by student.student_id, student_name;


This is what I'm currently using.
Are you suggesting I union after this whole statement like:

.
.
.
union
select student.student_id, student_name, 0 as n_classes /*new variable name?*/
from student

Name: Anonymous 2008-10-29 20:23

>>5
Lol, you don't need to go through all of that hassle just to select 0. This reminds me of those obfuscated programming contests, where they write those large programs just to do "hello world".

Name: How to count 0 2008-10-29 20:37

No, I want it to print out a table.

STUDENT_ID STUDENT_NAME         COUNT(STUDENT.STUDENT_ID)
---------- -------------------- -------------------------
      1004 Ivy Chang                                    2
      1006 Tom Taylor                                   2
      1003 John Smith                                   6
      1002 David Baker                                  1
      1001 James Walter                                 4
      1005 James Fowler                                 1
Like this, except there's a STUDENT_ID 1007 named Tom Taylor
(teacher thinks she's being tricky)
Who has signed up for no classes.
Blasted thing is, even counting the null comes up with 1.
Could I use something else to have it simply count 0 for him, despite counting starting at 1?

Name: Anonymous 2008-10-29 20:50

COUNT(STUDENT.STUDENT_ID)
there's a STUDENT_ID 1007
counting the null comes up with 1

1007 is not null

Name: How to count 0 2008-10-29 22:11

We're so lazy....
I got it though. Thanks for the support.
Especially the first reply, I found much inspiration from him.

It involved with the normal count as the first query(as a view)
Then another that had 0 for the select of null(as a view)
Then a union of them both.

Name: Anonymous 2008-10-29 22:48

>>9
You suck massively at SQL. I hope you realise this.

Name: Anonymous 2008-10-29 23:19

>>10
Why else would he be learning sequel.

Name: Anonymous 2008-10-30 4:45

>>11
squirrel

Name: Anonymous 2008-10-30 6:29

>>12
suckle

Name: Anonymous 2008-10-30 10:38

>>5
Fixed your SQL in 5 seconds:

select student.student_id, student_name, count(student.student_id)
from student left join enrolls on
(student.student_id=enrolls.student_id)
group by student.student_id, student_name;


>>3
UNION failure.

Name: 8 2008-10-30 11:36

Fixed your SQL in 5 seconds:
Nope.

Name: Anonymous 2008-10-30 11:45

>>9
(as a view)
You did it wrong. Enjoy your poor marks.

Name: Anonymous 2008-10-30 15:22

>>14
SQL is an interesting programming language. I might learn it someday. I don't understand why it's so complicated though, with its GROUP BY and LEFT, RIGHT, CROSS JOINs.

Name: Anonymous 2008-10-30 15:29

Just as a little aside, I hope I'm not derailing the thread here, but how do you guys pronounce SQL?
1) Sequel
2) Squill
3) Sickle/Suckle
4) Ess-queue-elle

Name: Anonymous 2008-10-30 16:20

>>18
SSSSSSSSSCCCCHHHHHHHHHHHQQWWWEEEEEEEEEEEEEEEEEEEEEELLL

Name: Anonymous 2008-10-30 16:22

Sehkwihley

Name: Anonymous 2008-10-30 16:24

>>18
3) Sequel (faggot)

Name: Anonymous 2008-10-30 16:27

>>21
1) Sickle/Suckle (faggot)
2) Squill (faggot)
3) Sequel (faggot)
4) Ess-queue-elle  (faggot)
5) Other (faggot)

Name: Anonymous 2008-10-30 16:56

>>22
It would seem all paths lead to faggot.

Name: Anonymous 2008-10-30 16:57

>>22
(faggot) only goes behind the correct pronunciation (faggot)

Name: Anonymous 2008-10-30 17:06

>>24
It's actually quite interesting you would mention that. You see, I'm the one who invented the Pronunciation Thread meme. The idea was that the first two would be "wrong-but-plausible" pronunciations, with the third being the correct one but with a (faggot) annotation. The reader would be forced to select the correct option, albeit resign to declaring themselves homosexual. It's actually quite interesting, what's the best recourse in that situation? Do you be correct yet faggot, or do you evade faggotness and be wrong?
These are the questions which keep me up at night.

Name: Anonymous 2008-10-31 1:12

>>25
Interestingly, I'd rather be correct and a faggot, than wrong(and potentially still a faggot anyway.)

Name: Anonymous 2008-10-31 2:13

>>26
I would like to interview you.

Name: Anonymous 2008-10-31 22:16

>>25
It's a simple and straightforward answer for someone who's already a faggot. Therefore this meme appeals to homosexuals.

As the creator, perhaps you are also a homosexual?

Name: ​​​​​​​​​​ 2010-10-23 20:51

Name: Anonymous 2011-02-03 1:48

<

Name: Anonymous 2013-01-18 22:24

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Name: Anonymous 2013-01-19 23:08

restoring...

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List