Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2016
    Posts
    1

    Unanswered: Simple query help

    Hello, i am rather new to SQL and im having some struggles with queries. I have a general understanding of some statements. Like SELECT, COUNT, DISTINCT, and FROM. But i have the hardest time when it comes to grouping tables together or using sub queries i get highly confused and ends up leading to frustration and not figuring it out.
    I have a database that has two tables both with the exact same columns and almost the same data. Its a database with geoip data.
    Columns: visits id, ip, country_code, country_name, region_code, region_name, city, zip_code, time_zone, latitude, longitude, metro_code
    So i just have a couple queries i would like help with.
    This is what im trying to acheieve.

    1.) How many rows/records ipv4 ips vs ipv6?
    2.)List some non-US style zips (limit 10)
    3.)Top 20 ip's with most visits.
    4.)How many rows/records have NULLS/bad data?
    5.)Counts of visits in Northern Hemisphere vs Southern Hemisphere

    I really appreciate your time and help if there is any. Thanks

  2. #2
    Join Date
    Sep 2007
    Location
    Bangalore India
    Posts
    29
    Hi,

    1.How many rows/records ipv4 ips vs ipv6?
    Not sure about the fields.

    2.List some non-US style zips (limit 10)
    Select country_code,country_name,zip_code from geoip where zip_code!='No-us'

    3.Top 20 ip's with most visits.
    select count(ip) cntIP,ip from geoip group by ip order by cntIP desc limit 20

    4.How many rows/records have NULLS/bad data?
    Again not sure which field you are trying to access

    select country_name from geoip where country_name is null

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •