Plotting data R [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a simple tasks I would like to do. Using an RODBC connection I have connected R to a SQL server database. There are four tables in the database and they are tenors of Libor rates
Libor_1_mos
Libor_3_mos
Libor_6_mos
Libor_12_mos
Each table has two columns. The first column shows dates and the second column shows rates.
I would like a simple chart that plots the rates based on the dates in column 1. Straightforward - that is all that needs to be done. The x-axis should be dates (column 1) and the y axis should be rates (column 2). Note it is 5 years worth of data so showing every possible date on the x-axis may not be feasible.
Here is my work so far I am using the Libor_3_mos as an example
threemosdata <- sqlQuery(con,"select * from Libor_3_mos)
Using that line I can read the data from the table. So for instance
colnames(threemosdata)
will give me the names of the column in the table.

So this worked lovely
> date <- (threemosdata$observation_date)
> rates <- (threemosdata$USD3MTD156N)
> plot(date,rates)

Related

I need the sql query to get outout like below. I have some test files and need output like below [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
Table
Company1 Table
Company2 Table
I need to calculate below details year wise (as given in the output) for each company and also need the output in consoilidated level. Calculation logic also written in 2nd column.
Required Output Company level (2 outputs)
Required Output consolidated level (1 output)
instructioins
must produce 2 types of output in excel
a. At the Company Level
b. At the Consolidated Level
total 3 output
2 company level
1 consoliodated level
tried using pivot function but not able to solve

Creating a measure from two columns present in two different fields [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
I am new to Power BI. I know how to create a measure between two columns present within a field. But how do I create a measure from two different columns present in two different fields (IVIGUsage and TargetvsActuals?
I need to create a measure for gram variance and grams to target. So, could you please help me out? Earlier I had created the measure based on the one field targetvsactual which are as:
%GM_Target = Calculate(
DIVIDE(
Sum('TargetVsActuals'[Total_Grams]),
SUM('TargetVsActuals'[Target_Grams])))
Gram Variance = (Sum('TargetVsActuals'[Target_Grams]) - Sum('TargetVsActuals'[Total_Grams]))
So, this has to be modified. Please help me out.

Is there a faster way to add new column data with hundreds of rows? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
I have a decent-sized table 'countries' with about 10 columns. I recently added a new column to the table 'GDP' and I am entering the information per row using
UPDATE countries
SET GDP=(value)
WHERE name = (country);
I have 200 countries in this table. Is there a better way to update this information?
This project is from Khan Academy. We are asked to select a database and run queries on it. The data was pulled from https://gist.github.com/pamelafox/ad4f6abbaac0a48aa781
I am just making sure that there isn't a more efficient way of adding this information to the existing table 'countries' where the primary key is the name of the country.

Need RegEx to filter dataset according to specific position in string [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Want to filter dataset with SQL query using RegEx to filter entries based on the time (hour) e.g. 19:XX or 09:XX. The hour part of the string would be in position 12 and 13.
Checked a few other questions and articles, but I'm very new to this and can't figure it out. Don't know which SQL database it is, but I work with it on Google BigQuery.Thanks for your help!
Screenshot of data entries
The standard way to access the hour in a date/time is:
where extract(hour from timecol) = 19
Not all databases support extract. All should have something similar.

Does someone know how can I connect multi-DB-servers for clearing code or samples [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have found out a lot of messages from stack overflow but it is too much information to me , and I didn't see any clear code ,I wish I can use like as below URLs with easy way
Querying data by joining two tables in two database on different servers
Selecting data from two different servers in SQL Server
PS: sorry for all , maybe my English isn't very well ,so that I cannot understand or know , hopefully someone can give me a very simple code
This sample is very easy , hopefully it is you want
1.Data Source <=Server ip or ServerName
2.Initial Catalog <= DB Name
3.User ID <= Account ID
4.Password <= Account PWD
5.[*****].[dbo].[awards] <= which table you want to find out
SELECT *
FROM OPENDATASOURCE('SQLNCLI',
'Data Source=10.***.***.***;Initial Catalog=B2C**;User ID=****;Password="****"')
.[*****].[dbo].[awards]
PS: more detail you can see
https://msdn.microsoft.com/zh-tw/library/ms179856(v=sql.120).aspx
or Querying data by joining two tables in two database on different servers
or Selecting data from two different servers in SQL Server
it will be gave you more detail ways or methods