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
VeteranXX
Contributor
Old
1 - 09-21-2017, 14:50
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 online now
 
Sponsored Links
HaPpY
VeteranXX
Old
2 - 09-21-2017, 14:55
Reply With Quote
INSERT INTO butthole VALUES(cock, aids, hamster)
 
HaPpY is offline
 
Kerosene31
VeteranXV
Old
3 - 09-21-2017, 14:58
Reply With Quote
select * from doyourown****inghomework

Hint: the words "group by" and "having" might be useful
 
Kerosene31 is offline
 
BeLiaL
VeteranXX
Old
4 - 09-21-2017, 14:58
Reply With Quote
stackoverflow or google
 
BeLiaL is offline
 
havax
VeteranXV
Contributor
Old
5 - 09-21-2017, 14:59
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
VeteranXX
Contributor
Old
6 - 09-21-2017, 15:02
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 online now
 
The Pumpkin King
VeteranXX
Old
7 - 09-21-2017, 15:08
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
VeteranXX
Contributor
Old
8 - 09-21-2017, 15:33
Reply With Quote
Shouldn't you be out helping your neighbors recover from the storms?
 
Mr Jimmy Pop is offline
 
JuggerNaught
VeteranXX
Contributor
Old
9 - 09-21-2017, 15:35
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 online now
 
JuggerNaught
VeteranXX
Contributor
Old
10 - 09-21-2017, 18:25
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 online now
 
havax
VeteranXV
Contributor
Old
11 - 09-21-2017, 18:38
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, 18:40
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, 18:42
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
VeteranXX
Contributor
Old
14 - 09-21-2017, 18:45
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 online now
 
BeLiaL
VeteranXX
Old
15 - 09-21-2017, 18:59
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
VeteranXX
Old
16 - 09-21-2017, 21:44
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
VeteranXX
Contributor
Old
17 - 09-21-2017, 21:51
Reply With Quote
SELECT * FROM DICKS
UNION
SELECT * FROM BUTTS
 
Brasstax is offline
 
JuggerNaught
VeteranXX
Contributor
Old
18 - 09-21-2017, 23:38
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 online now
 
Brasstax
VeteranXX
Contributor
Old
19 - 09-21-2017, 23:42
Reply With Quote
This is going to be a painful class.
 
Brasstax is offline
 
Brasstax
VeteranXX
Contributor
Old
20 - 09-21-2017, 23:46
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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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: claudebot / Y
All times are GMT -4. The time now is 09:51.