VeteranXX Contributor
|
Working on some homework. I have a table of 'trips' with 41 entries.
The columns are TRIP_ID, TRIP_NAME, START_LOCATION, STATE, DISTANCE, MAX_GRP_SIZE, TYPE, SEASON
I need to find how many trips originate from each state
I know I can get the overall count with
SELECT COUNT STATE
FROM TRIP
But i can't figure out the syntax for the query to separate the count for each state.
I've been trying something like
SELECT COUNT STATE
FROM TRIP
WHERE STATE IN ('NJ', 'NY', 'NH')
But thats not separating this to counts for each state
Any help would be appreciated.
|
|
|
VeteranXX
|
INSERT INTO butthole VALUES(cock, aids, hamster)
|
|
|
VeteranXV
|
select * from doyourown****inghomework
Hint: the words "group by" and "having" might be useful
|
|
|
VeteranXX
|
stackoverflow or google
|
|
|
VeteranXV Contributor
|
Quote:
Originally Posted by Kerosene31
select * from doyourown****inghomework
Hint: the words "group by" and "having" might be useful
|
yep
|
|
|
VeteranXX Contributor
|
Quote:
Originally Posted by Kerosene31
select * from doyourown****inghomework
Hint: the words "group by" and "having" might be useful
|
got it...thanks
|
|
|
VeteranXX Contributor
|
Shouldn't you be out helping your neighbors recover from the storms?
|
|
|
VeteranXX Contributor
|
Nah, most everyone around here is good to go. We got a lot of tree damage, lost a bit of power, but other than that it was relatively 'minor'.
|
|
|
VeteranXX Contributor
|
What is a query generator for sql? Right now the class has us using oracle application express. There has to be something easier than this
|
|
|
VeteranXV Contributor
|
Quote:
Originally Posted by JuggerNaught
What is a query generator for sql? Right now the class has us using oracle application express. There has to be something easier than this
|
don't rely on visual query generators. that's noob ****, and will keep you noobish. tough it out, bro.
|
|
|
VeteranXV
|
Pick up a cheap used copy of the Ben Forta "Teach Yourself SQL in 10 minutes" (3rd or 4th edition). You will learn everything that you reasonably need to learn about SQL queries within 3-4 hours.
|
|
|
VeteranXV
|
Quote:
Originally Posted by havax
don't rely on visual query generators. that's noob ****, and will keep you noobish. tough it out, bro.
|
My limit is about 5 joins until I say **** it, and use a visual editor.
|
|
|
VeteranXX Contributor
|
I have the basic concepts, but the syntax is whats jacking me up. I've been messing with this query now for about an hour and I can only get so far before i get syntax errors. Surely a visual query generator would make this whole thing much easier
|
|
|
VeteranXX
|
Quote:
Originally Posted by JuggerNaught
I have the basic concepts, but the syntax is whats jacking me up. I've been messing with this query now for about an hour and I can only get so far before i get syntax errors. Surely a visual query generator would make this whole thing much easier
|
but then you won't learn anything
like how to structure your queries logically
|
|
|
VeteranXX Contributor
|
SELECT * FROM DICKS
UNION
SELECT * FROM BUTTS
|
|
|
VeteranXX Contributor
|
ok...figured it out. It just dawned on me that the aggregate statements go across the rows, not down the columns. sql noob status achieved.
|
|
|
VeteranXX Contributor
|
This is going to be a painful class.
|
|
|
VeteranXX Contributor
|
SELECT ****.*
FROM (
SELECT *
FROM ****BAG
WHERE ****_TYPE = 'RUNNY'
) AS ****
WHERE ****.CONSTIPATION = 'FALSE'
Headstart on subqueries
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
AGENT: claudebot / Y
All times are GMT -4. The time now is 05:48.
|