Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Very new to SQL

Author  Topic 

DJS051085
Starting Member

3 Posts

Posted - 2013-06-03 : 15:05:26
Hi All -

I'm very new to SQL. I started using it inside of RealBasic but I think I might be better off learning the language in its native environment before trying to call it from RB. Any suggestions on a good compiler (free for mac)?

Also, I'm trying to figure out... Is it possible to create more than one table within a database? Or is each database defined by a single table of data? If I can create more than one table in a database, is it possible to browse a database for all tables contained therein?

My project is to effectively look at a certain time period and a certain number of stocks. So... I need to be look at the k-th value of the j-ith stock on the i-th day. I was told SQL was the way to do this. I wonder if it would be better to simply have one set of values per table, e.g. market capitalization, separated by time (row) and stock ticker (column) and then have several tables (one for price, one for earnings, etc.)

Any help is much appreciated.

MTSPEER
Starting Member

6 Posts

Posted - 2013-06-03 : 15:31:09
Yes you can can have more than one table withing a database. And also you can join tables together. And I don't think you need many tables for the database you're trying to create. What you just said(stock ticker, and time) aren't entities. It would be easier just to make one table.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-03 : 23:50:25
The solution would be to have single table with Stock,datetime,uniqueid so that you can get nth value of stock for a particular date
the query would be like

SELECT stock
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY uniqueid) AS Rn,*
FROM table
WHERE datetime = @yourPasseddatevalue
)t
WHERE Rn=@N


N and date value you can pass as you want by creating parameters as above

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

DJS051085
Starting Member

3 Posts

Posted - 2013-06-04 : 12:12:35
Okay - this makes sense. Pretty straight forward I think. Thanks guys.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-04 : 13:02:05
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -