I have 3 columns : year, price, and day_type. year day_type price 2016 0 10 2016 1 20 2016 2 5 2017 0 14 2017 1 6 2017 2 3 I want to keep only the lines where day_type = 1 or 2, but add to these …
Tag: sql
Extracting Data from SQL Server Table within a Schema
I am having a hard time writing and extracting data from SQL Server in RStudio. My database hierarchy is as follows: LDS LDS HIG table_needed I’ve tried: ch <- DBI::dbConnect(odbc::odbc(), "…
How do I select birthdays in the next 30 Days
I have a table with birthdates and I want to select all the birthdays that will come in the next 30 days. The situation is, that all the birthdays are written in the form off 1999-09-15 which means that even if I tried selecting the next 30 days, the birthdays wouldn’t show up because the year is 1999. …
I am struggling to remove the last 30 characters from data in a column
I am looking to remove the last 30 characters from a colum within my database. I have created the below which works in the sense it shows me the result and it’s correct but it does not commit or change anything. What am I missing, I am a noob 🙂 I expect the data in the column to remove the
Executing multiple drop table statements in 1 sql file
I am trying to drop 200 tables from my database and save the sql statements to 1 .sql file so they can be run in one go on each copy of the database. I would like to use a separate drop table statement for each table so I can easily reference what line any errors appear on. I have tried
Adding Random Id for each unique value in table
I have the table like I want the result to be like : The same ID should have same random_ids. I’m using the update statement to generate the Random_IDs after creating the table. Is there something else that I need to add to the update statement? Please advise. Answer Why would you use update for this? J…
T-SQL Query Column based on filtered condition
I could do this rather easily in Python (or any other language), but I’m trying to see if this is possible with pure T-sql I have two tables: Table A has a bunch of general data and timestamps with each row Table B is considered metadata So the general data is referenced to a “RunNo”. The ti…
How can i count project status by change/update made
I want to count status change by id from to I have a mysql status table which has a name with pre implementation, implementation and operations states. a project contains project id, name, start date fields. both status and projects have a many to many relationship called project_status table contains project…
Efficient way to map new values to a sql query (i.e 4 columns each with same credentials)
First I am new to Postgres so I may be describing this problem incorrectly so please point me to an answer if it has already been answered. I have a database with 10 columns. Lets say 4 columns all use the same codes for values (i.e the letter a, b, d, e) I want to rename all of these in
How to use multiple select queries inside c# by oracle
I need to select multiple select queries inside the C# code block. when I use it, I am getting an error such as an invalid character. I got that it is an error by using a semicolon inside the queries, Is there any solution for selecting multiple select queries? I am using Oracle.ManagedDataAccess ExecuteReade…