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
Old
21 - 09-22-2017, 07:13
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
VeteranXX
Contributor
Old
22 - 09-22-2017, 08:07
Reply With Quote
SQL like a pig boy
 
Mr Jimmy Pop is online now
 
Brasstax
VeteranXX
Contributor
Old
23 - 09-22-2017, 11:42
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
VeteranXX
Old
24 - 09-22-2017, 15:50
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
Tribalwar Admin
Old
25 - 09-22-2017, 17:18
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 online now
 
BeLiaL
VeteranXX
Old
26 - 09-22-2017, 17:27
Reply With Quote
it's juggs, keep that in mind
 
BeLiaL is offline
 
Ddrakon
VeteranXV
Old
27 - 09-22-2017, 17:55
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
VeteranXX
Old
28 - 09-22-2017, 19:13
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


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 19:19.