SELECT Statement Workout
- 02:39
How to write the SELECT Statement
Downloads
Transcript
So let us now try having a go at how to use the select statement.
In the S developer IDE, we already have a data set. We have inputted a data set called historical data into the database.
This data set has the historical stock prices or share prices of certain thickers in the s and p 500.
So let's try to use the select statement to view all the columns from this particular dataset.
So select statement initially starts with Select Select, and then because we want to select all columns from the database, we use star.
And then we've got to mention the data set or the table name that we want to get the data from.
For this, we use the form statement and we specify the table name, which in this case is historical data, and we edit with a semicolon to run it.
We can either go to the top hand, top left hand side and press the run statement, or we could use the shortcut, which is control enter, and we have to choose an existing connection, which is the local SIS stands for local system.
And this would essentially give us the output, which is in the table format, which is the historical data.
As you can see, we've got the company name, we've got the tickers, we've got the date opening value, highest value, lowest value, closing value, and other relevant column names.
Let's say now that we want to just select the column ticker to do this, we say select ticker from historical data and we end it with a semicolon. We can run this again using the shortcut control enter, it's gonna just give us the ticker column.
Now say we want the ticker column and also the opening value.
To do this, we can just say open, and we can again run this with the shortcut control enter.
This is gonna give us the ticker and the opening value.
Okay. We can say we want the company name ticker, and then the opening value.
We can also say that select company ticker, and then the opening value with the funders using the shortcut control enter.
This would return us the respective company column, ticker column, and the opening value column.