• Best of luck to the class of 2024 for their HSC exams. You got this!
    Let us know your thoughts on the HSC exams here
  • YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page
MedVision ad

SQL Question (1 Viewer)

FadeToBlack

lonely sunday friend
Joined
Aug 11, 2002
Messages
435
Location
jesus
Gender
Male
HSC
2003
22 b, right?
This confused me, becase i'm not 100% on SQL, and i was unsure what dto do whebn it said find all the friends in NSW, but it didnt ask to show the state field (First names, Last names and Home phone only)

so i got soemthing like:

SELECT: First_name, Last_name, Home_phone
FROM: FRIENDS
WHERE: State = NSW
ORDER BY: Descending Alphabetical (had no idea about this part)

how many marks outta 3, you reckon?
 

Huy

Active Member
Joined
Dec 20, 2002
Messages
5,240
Gender
Undisclosed
HSC
N/A
Um... I did this in another thread.

SELECT Last_name, First_name, Home_phone, State
FROM FRIENDS
Where State="NSW"
ORDER BY Last_name DESC

Fade, I don't think you're allowed to use colon's.
 

FadeToBlack

lonely sunday friend
Joined
Aug 11, 2002
Messages
435
Location
jesus
Gender
Male
HSC
2003
Originally posted by Huy
Um... I did this in another thread.


Fade, I don't think you're allowed to use colon's.
I cant remember if i did or not
Arg, would they penalise
 

Jeo

........
Joined
Apr 4, 2003
Messages
1,054
State in Select will probably lose one mark.

I will lose one mark for not putting NSW

Fade will lose one mark for using colons.. edit: Using colons like that in SQL is invalid syntax.

FARK that was the easiest Q aswell... damn
 

Jeo

........
Joined
Apr 4, 2003
Messages
1,054
Originally posted by gmraso
huy is write 100%( huy why weren't you sitting next to me in the exam?)
No he is not. Unfortunately. :(
 

Sparr0w

New Member
Joined
Oct 23, 2003
Messages
8
SELECT First_name, Last_name, Home_phone
FROM FRIENDS
Where State="NSW"
ORDER BY Last_name Asc

Is this correct?
 

honky tonk

in Miracle World
Joined
Dec 26, 2002
Messages
1,032
Location
Newcastle
Gender
Male
HSC
2003
I screwed up the ORDER BY part.. I wrote:

SELECT First_Name, Last_Name, Home_Phone
FROM FRIENDS
WHERE State = "NSW"
ORDER BY ASCENDING Last_Name

Hope I didn't lose too many marks.. :(
 

Huy

Active Member
Joined
Dec 20, 2002
Messages
5,240
Gender
Undisclosed
HSC
N/A
Originally posted by FadeToBlack
I cant remember if i did or not
Arg, would they penalise
I sure hope not! Just for a colon... BUT you have to remember, it probably won't work (SQL query) with the colon... when you program it.
Originally posted by Jeo
State in Select will probably lose one mark.

I will lose one mark for not putting NSW

Fade will lose one mark for using colons.. edit: Using colons like that in SQL is invalid syntax.
Yep, that's what I thought, it's incorrect syntax. It "looks right" but if you were to punch that into the computer, it won't work.

Jeo, "State in Select will probably lose one mark."
If you didn't select State, in "SELECT" (selecting fields), then where in the world would you take it from, when you are stating:

"WHERE State="NSW"" for example.
If you don't SELECT all fields required by the query, you won't be able to manipulate the query into giving you your final result (ORDER BY... DESC/ASC)

My 2 cents :)
Originally posted by gmraso
huy is write 100%( huy why weren't you sitting next to me in the exam?)
I'm right... or write? ;) just kidding buddy.

I was sitting next to 1 person, but I had no one around me pretty much.


x x o
x Me o
o o o

O's = free/empty seats

:)
 

FadeToBlack

lonely sunday friend
Joined
Aug 11, 2002
Messages
435
Location
jesus
Gender
Male
HSC
2003
The SQL question was misleading, then

"show only first names, last names and home phones"

giving you nowhere to put "State" which is needed to sort
 

Huy

Active Member
Joined
Dec 20, 2002
Messages
5,240
Gender
Undisclosed
HSC
N/A
Originally posted by Sparr0w
SELECT First_name, Last_name, Home_phone
FROM FRIENDS
Where State="NSW"
ORDER BY Last_name Asc

Is this correct?
Asc should be ASC, and as Jeo has said, Where should be WHERE.

Also, why didn't you SELECT State as well?

Selecting first, last and (home) phone number will let the query "look up" ONLY those 3 fields, and therefore your query and criteria can only manipulate with those 3 fields, NOT the State.

So "WHERE State="NSW"" wouldn't work, because it doesn't look up the ENTIRE FRIENDS table.
Originally posted by honky tonk
I screwed up the ORDER BY part.. I wrote:
ORDER BY ASCENDING Last_Name
Hope I didn't lose too many marks.. :(
ASC should be at the end,

It's either ASC or DESC, never "ASCENDING"

ORDER BY Last_name DESC

Ascending order = smallest to largest
Descending order = largest to smallest.

Which makes me think, whether I'm right or wrong.

I had DESC.

Ascending: A to Z, or Z to A?
Descending: Z to A, or A to Z?

I interpreted it as:

Descending, from "highest" (A) to "lowest" (Z).
Therefore it's alphabetical, by DESC.

I don't know... I'm thinking too hard about it :p
 

Jeo

........
Joined
Apr 4, 2003
Messages
1,054
You dont need to select it to search it dude.

Only SELECT what you want to display.
 

Jeo

........
Joined
Apr 4, 2003
Messages
1,054
You dont need to... I mean, just go to mysql site or any SQL site, you will see for criteria of WHERE, you do not SELECT it.
 

Huy

Active Member
Joined
Dec 20, 2002
Messages
5,240
Gender
Undisclosed
HSC
N/A
Originally posted by Jeo
You dont need to select it to search it dude.

Only SELECT what you want to display.
Okay, I'll have to give you the benefit of the doubt Jeo :)
You would know more than me with real-world "applications of IPT theory"

:)
Originally posted by Bandit
I can't wait to see the marking criteria for that one
I wouldn't mind having a gander either.
 

holl

Member
Joined
Oct 23, 2003
Messages
130
I said decending too. do u think u'd loose marks for not writing select etc in capitals and just writing big little letters if u no what i mean? It was only worth 3 marks, they can't be too picky.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top