AIDs Water5
|
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.
|
|
|
VeteranXV Contributor
|
INSERT INTO butthole VALUES(cock, aids, hamster)
|
|
|
VeteranXV Contributor
|
select * from doyourown****inghomework
Hint: the words "group by" and "having" might be useful
|
|
|
VeteranXV
|
stackoverflow or google
|
|
|
VeteranX Contributor
|
Quote:
Originally Posted by Kerosene31
select * from doyourown****inghomework
Hint: the words "group by" and "having" might be useful
|
yep
|
|
|
AIDs Water5
|
Quote:
Originally Posted by Kerosene31
select * from doyourown****inghomework
Hint: the words "group by" and "having" might be useful
|
got it...thanks
|
|
|
VeteranXV Contributor
|
Shouldn't you be out helping your neighbors recover from the storms?
|
|
|
AIDs Water5
|
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'.
|
|
|
AIDs Water5
|
10 - 09-21-2017, 05:25 PM
|
|
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
|
|
|
VeteranX Contributor
|
11 - 09-21-2017, 05:38 PM
|
|
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
|
12 - 09-21-2017, 05:40 PM
|
|
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
|
13 - 09-21-2017, 05:42 PM
|
|
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.
|
|
|
AIDs Water5
|
14 - 09-21-2017, 05:45 PM
|
|
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
|
|
|
VeteranXV
|
15 - 09-21-2017, 05:59 PM
|
|
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
|
|
|
VeteranXV Contributor
|
17 - 09-21-2017, 08:51 PM
|
|
SELECT * FROM DICKS
UNION
SELECT * FROM BUTTS
|
|
|
AIDs Water5
|
18 - 09-21-2017, 10:38 PM
|
|
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.
|
|
|
VeteranXV Contributor
|
19 - 09-21-2017, 10:42 PM
|
|
This is going to be a painful class.
|
|
|
VeteranXV Contributor
|
20 - 09-21-2017, 10:46 PM
|
|
SELECT ****.*
FROM (
SELECT *
FROM ****BAG
WHERE ****_TYPE = 'RUNNY'
) AS ****
WHERE ****.CONSTIPATION = 'FALSE'
Headstart on subqueries 
|
|
|
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: CCBot/2.0 (http://commoncrawl.org/faq/) / Y
All times are GMT -5. The time now is 03:23 PM.
|