SQL Help please by JuggerNaught - TribalWar Forums
Click Here to find great hosting deals from Branzone.com


Go Back   TribalWar Forums > TribalWar Community > General Discussion
Reload this Page SQL Help please
Page 1 of 2
Thread Tools
JuggerNaught
AIDs Water5
Old
1 - 09-21-2017, 02:50 PM
Reply With Quote
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.
 
JuggerNaught is offline
 
Sponsored Links
HaPpY
VeteranXV
Contributor
Old
2 - 09-21-2017, 02:55 PM
Reply With Quote
INSERT INTO butthole VALUES(cock, aids, hamster)
 
HaPpY is offline
 
Kerosene31
VeteranXV
Contributor
Old
3 - 09-21-2017, 02:58 PM
Reply With Quote
select * from doyourown****inghomework

Hint: the words "group by" and "having" might be useful
 
Kerosene31 is offline
 
BeLiaL
VeteranXV
Old
4 - 09-21-2017, 02:58 PM
Reply With Quote
stackoverflow or google
 
BeLiaL is offline
 
havax
VeteranX
Contributor
Old
5 - 09-21-2017, 02:59 PM
Reply With Quote
Quote:
Originally Posted by Kerosene31 View Post
select * from doyourown****inghomework

Hint: the words "group by" and "having" might be useful
yep
 
havax is offline
 
JuggerNaught
AIDs Water5
Old
6 - 09-21-2017, 03:02 PM
Reply With Quote
Quote:
Originally Posted by Kerosene31 View Post
select * from doyourown****inghomework

Hint: the words "group by" and "having" might be useful
got it...thanks
 
JuggerNaught is offline
 
The Pumpkin King
VeteranXV
Old
7 - 09-21-2017, 03:08 PM
Reply With Quote
Here, I googled it for you.

oracle - SQL query to count number of objects in each state on each day - Stack Overflow
 
The Pumpkin King is offline
 
Mr Jimmy Pop
VeteranXV
Contributor
Old
8 - 09-21-2017, 03:33 PM
Reply With Quote
Shouldn't you be out helping your neighbors recover from the storms?
 
Mr Jimmy Pop is offline
 
JuggerNaught
AIDs Water5
Old
9 - 09-21-2017, 03:35 PM
Reply With Quote
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'.
 
JuggerNaught is offline
 
JuggerNaught
AIDs Water5
Old
10 - 09-21-2017, 06:25 PM
Reply With Quote
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
 
JuggerNaught is offline
 
havax
VeteranX
Contributor
Old
11 - 09-21-2017, 06:38 PM
Reply With Quote
Quote:
Originally Posted by JuggerNaught View Post
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.
 
havax is offline
 
Slurp
VeteranXV
Old
12 - 09-21-2017, 06:40 PM
Reply With Quote
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.
 
Slurp is offline
 
Slurp
VeteranXV
Old
13 - 09-21-2017, 06:42 PM
Reply With Quote
Quote:
Originally Posted by havax View Post
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.
 
Slurp is offline
 
JuggerNaught
AIDs Water5
Old
14 - 09-21-2017, 06:45 PM
Reply With Quote
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
 
JuggerNaught is offline
 
BeLiaL
VeteranXV
Old
15 - 09-21-2017, 06:59 PM
Reply With Quote
Quote:
Originally Posted by JuggerNaught View Post
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
 
BeLiaL is offline
 
The Pumpkin King
VeteranXV
Old
16 - 09-21-2017, 09:44 PM
Reply With Quote
Use code wars.

Codewars - Kata Retrospective: SQL Basics: Simple GROUP BY | Codewars

This problem features the exact question that you asked.

You can hone your skills here.
 
The Pumpkin King is offline
 
Brasstax
VeteranXV
Contributor
Old
17 - 09-21-2017, 09:51 PM
Reply With Quote
SELECT * FROM DICKS
UNION
SELECT * FROM BUTTS
 
Brasstax is offline
 
JuggerNaught
AIDs Water5
Old
18 - 09-21-2017, 11:38 PM
Reply With Quote
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.
 
JuggerNaught is offline
 
Brasstax
VeteranXV
Contributor
Old
19 - 09-21-2017, 11:42 PM
Reply With Quote
This is going to be a painful class.
 
Brasstax is offline
 
Brasstax
VeteranXV
Contributor
Old
20 - 09-21-2017, 11:46 PM
Reply With Quote
SELECT ****.*
FROM (
SELECT *
FROM ****BAG
WHERE ****_TYPE = 'RUNNY'
) AS ****
WHERE ****.CONSTIPATION = 'FALSE'

Headstart on subqueries
 
Brasstax is offline
 
Page 1 of 2
Reply


Go Back   TribalWar Forums > TribalWar Community > General Discussion
Reload this Page SQL Help please

Social Website Bullshit

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

AGENT: CCBot/2.0 (http://commoncrawl.org/faq/) / Y
All times are GMT -5. The time now is 04:19 PM.