SQL Help please

JuggerNaught

Contributor
Veteran XX
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.
 
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'.
 
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
 
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 shit, and will keep you noobish. tough it out, bro.
 
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.
 
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
 
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
 
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.
 
SELECT SHIT.*
FROM (
SELECT *
FROM SHITBAG
WHERE SHIT_TYPE = 'RUNNY'
) AS SHIT
WHERE SHIT.CONSTIPATION = 'FALSE'

Headstart on subqueries :)
 
Back
Top