5 Replies - 1311 Views - Last Post: 20 February 2013 - 02:18 PM

#1 troyb408  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 18-August 12

Query one row of data in huge database

Posted 20 February 2013 - 12:30 PM

Hell All -

Thank you in advance to those that decide to help. I'm a new programmer and have been tasked with writing and creating a stored procedure. But I struggle with sql queries. His is what my data base is comprised of.

Type r_Code code Year Mean Entry experienced pct10 pct25 pct50 pct75 pct90
1 1 11-1011 2011 15950 23242.50 1859.40 15495 38737.50 77475 11612.50 139455
1 1 11-1021 2011 15184 5441618 1849815 164848 18948 15418 154185 156968
1 1 11-1031 2011 18968418 95784 18548 151841 125418 15814 15418 1541



In this table there are over 3500 rows all for year 2011
Region Type remains 1
Region Code can goes from 1-5
Code - I'm not really sure but it increments steadily

What I am having difficulty with is running a query that will only return one row of data. Attached is a picture this came out kinda ugly

This post has been edited by troyb408: 20 February 2013 - 12:32 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Query one row of data in huge database

#2 troyb408  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 18-August 12

Re: Query one row of data in huge database

Posted 20 February 2013 - 01:12 PM

Nevermind I figured it out...

SELECT DISTINCT region_type, region_code, soc_code, year, mean, entry, experienced, pct10, pct25, pct50, pct75, pct90
FROM fact_OccWagesOverTime
WHERE region_code = 5(user defined)
AND region_type = 2(user defined)
AND soc_code = ('11-1011')(user defined)
ORDER BY mean DESC
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3485
  • View blog
  • Posts: 11,891
  • Joined: 12-December 12

Re: Query one row of data in huge database

Posted 20 February 2013 - 01:31 PM

FWIW You can also start the (ms)sql with SELECT TOP 1.
Was This Post Helpful? 0
  • +
  • -

#4 troyb408  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 18-August 12

Re: Query one row of data in huge database

Posted 20 February 2013 - 01:36 PM

That's originally how I started doing it but then wouldnt have been accurate for future years. The code field is just a list of types that the user choses based on the year so the query needed to be flexible.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3485
  • View blog
  • Posts: 11,891
  • Joined: 12-December 12

Re: Query one row of data in huge database

Posted 20 February 2013 - 01:44 PM

No worries :)

BTW 3500 rows is tiny in database terms! Some databases deal in terabytes.

Quote

terabyte: A unit of information equal to one million million (1012) or strictly, 240 bytes.


Top 10 Largest

Although, these are not really single databases. (Sorry, just found this interesting!)

This post has been edited by andrewsw: 20 February 2013 - 01:45 PM

Was This Post Helpful? 0
  • +
  • -

#6 troyb408  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 18-August 12

Re: Query one row of data in huge database

Posted 20 February 2013 - 02:18 PM

Crazy well this being my first job outta college in class had a few databases that were only few hundred rows so this seemed like a ton. Still that amazement and I know I'll have more questions posted on here for better insight as I go along
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1