SQL Help please by JuggerNaught - Page 2 - 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 2 of 2
Thread Tools
Kerosene31
VeteranXV
Contributor
Old
21 - 09-22-2017, 06:13 AM
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
Learning SQL is weird like that. You bang your head against a wall until you just get it. There's just no good way to teach it. It isn't like you can really learn it incrementally.

I can write that query for you in 2 seconds, but I would have a heck of a time explaining actually how to do it.
 
Kerosene31 is offline
 
Sponsored Links
Mr Jimmy Pop
VeteranXV
Contributor
Old
22 - 09-22-2017, 07:07 AM
Reply With Quote
SQL like a pig boy
 
Mr Jimmy Pop is offline
 
Brasstax
VeteranXV
Contributor
Old
23 - 09-22-2017, 10:42 AM
Reply With Quote
That's a pretty mouth boy----

Yeah Juggs - it kinda pops into place as you learn the concepts. SQL syntax is always a little bit of a pain in the ass - but learn to work in small blocks and strap it together.

Also - just a rule I have found useful - if your query takes more than a few seconds - there is a way to optimize it. Either the query or the server (or how the query is stored (view/sproc/etc).

Anyway - have fun and make sure to come back for more TW style advice
 
Brasstax is offline
 
Flyersfan
VeteranXV
Old
24 - 09-22-2017, 02:50 PM
Reply With Quote
Quote:
Originally Posted by JuggerNaught View Post
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.
select count(trip_id) as [Trips],state
from trip
where state in ('nj','ny','nh')
group by state
 
Flyersfan is offline
 
Zanthious
VeteranX
Contributor
Old
25 - 09-22-2017, 04:18 PM
Reply With Quote
sql management studio....google...stacko verflow.... trial and error..

this is a 5 minute problem tops once you can query..

wtf.
 
Zanthious is offline
 
BeLiaL
VeteranXV
Old
26 - 09-22-2017, 04:27 PM
Reply With Quote
it's juggs, keep that in mind
 
BeLiaL is offline
 
Ddrakon
VeteranX
Old
27 - 09-22-2017, 04:55 PM
Reply With Quote
****ing around in the access gui might help if you really need the visual, but nothing beats figuring out in pure sql mode

aggregation is pretty basic anyway
 
Ddrakon is offline
 
dr. nick
VeteranX
Old
28 - 09-22-2017, 06:13 PM
Reply With Quote
select state, count(distinct TRIP_ID) as numTrips
from trips
group by state
order by state asc
 
dr. nick is offline
 
Page 2 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 05:35 AM.