[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Any Robots know SQL? I would gift you a steam game for your trouble?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /r9k/ - ROBOT9001

Thread replies: 11
Thread images: 1
File: Lets go play melee.jpg (62 KB, 960x720) Image search: [Google]
Lets go play melee.jpg
62 KB, 960x720
Any Robots know SQL?

I would gift you a steam game for your trouble?
>>
>>26672067
I did some in uni last year I could probably bullshit some for you
>>
>>26672139
Steam?

No cyboring pls.
>>
I've been doing it for awhile. What do you want to do?
>>
if you can get me a gf ill do it
>>
I'm a professional developer, have done SQL for years. Sup?

(don't want any games, v0v)
>>
>>26672516
Alright it's HW questions but I'm trying to find the highest scored Harry Potter Movie by Critics in a data base.

[code]Select Title,CRITICS_SCORE
from Movie
Where left(Title,12) = 'Harry Potter' =(
Where CRITICS_SCORE = SELECT MAX(CRITICS_SCORE)
FROM Movie
);
[/code]

Obviously I get an error but my thought process was I check to the Max critic scores and than see if the movie is a harry potter film.

I CAN'T USE LIMIT 1 in my example and trying to avoid using TOP 1.

earlier code I had that works but it shows every move with the same critics_score as The deathly hollows.

[code]
select Title, CRITICS_SCORE
from Movie
Where CRITICS_SCORE = (SELECT MAX(CRITICS_SCORE)
FROM Movie
Where Title like 'Harry Potter%'
);
[/code]
>>
>>26672902
Can't just use:

SELECT Title, MAX(CRITICS_SCORE) AS MAX_CRITICS_SCORE FROM Movie WHERE Title LIKE 'Harry Potter%'

? If there's multiple HP movies with the same (highest) critics score then there'll be >1 row returned, but I assume that's okay if you can't use LIMIT 1.
>>
>>26673092
Yeah but the results should a table with one row.
The database is basically from RT.com and a HW assignment had us convert it into a SQL database and this assignment is having you do different queries on it.
>>
>>26673161
Understood.

Have you learned about GROUP BY yet? I suppose that would be one way to do it. If CRITICS_SCORE is all the same values (i.e. your MAX) there'll just be one row returned when you use GROUP BY.

SELECT Title, CRITICS_SCORE
FROM Movie
WHERE Title LIKE 'Harry Potter%'
AND CRITICS_SCORE = (
SELECT MAX(CRITICS_SCORE) FROM Movie WHERE Title LIKE 'Harry Potter%'
)
GROUP BY CRITICS_SCORE;

I modified your second query a bit (not much though, just added the second WHERE TITLE). It seems to work fine on some test data.

If you can't use LIMIT, I can't see any other obvious ways to do it (other than possibly with joins)
>>
>>26673346
Thanks alot Anon.
Got 3 Queries left to write, gonna take a break and tackle them. Hopefully I get this done by 12:00PM EST.
Thread replies: 11
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.