I’m trying to write a SQL script that shows a column based on a user parameter. I can’t find an acceptable answer anywhere. This is a simplified version of what I want to do (in OracleDB): The pseudo code of what I want could be This is the expected result: Answer You can just put the logic into …
Tag: sql
Connect to SQL Server in Python with ReadOnly
I am trying to connect to the SQL server in python using pyodbc. I am unable to connect because my database is ReadOnly. I tried the solutions provided at other link: But, I am still getting the following error: ProgrammingError: (‘42000’, “[42000] [Microsoft][ODBC SQL Server Driver][SQL Ser…
Suggested way to resolve column name/type in a view
I have the following problem that I’m trying to find the best solution for. Let’s say I have a view such as the following: What would be the fastest way to resolve the field names and types of the view? For example, on the above I am looking to get something along the lines of: The first approach …
There are duplicate records in table, we need to select only the latest records as per date using group by or window function in sql
There are duplicate records in table, we need to select only the latest records as per date using group by or window function in sql code: Answer You can simply use a GROUP BY like so If you want to use ROW_NUMBER you have to PARTITION BY the id
How to Update some records with still maintain other records in Codeignitter?
Table Info : id-data id-note note 1 5 I went home with John Harrison 2 5 I had dinner with John Harrison 3 5 I went shopping with John Harrison 4 3 I had dinner with John Harrison I want to update “John Harrison” in note where id-note (5), with “Sebastian” but still maintain the other …
Can I get the full rows when using group by multiple columns?
If the date, item, and category are the same in the table, I’d like to treat it as the same row and return n rows out of them(ex: if n is 3, then limit 0, 3). expected results (if n is 3) The problem is that I have to bring the values of each group as well. If I have
SQL | C# – Reader rows
I have a small problem with MySqlDataReader. I have data in MySql and I have column “name” and X rows under. Reader reads sucessfully all of this but output is in one string and looks like “FirtSecondThird” but i need all of this words in list word by word. The code is: Does anyone kno…
How to change data type in csv column
Using databricks with SQL, I have to import my csv dataset into a table and analyse data using it. My problem is after I imported csv dataset, all column are String type, but some of these need to be Numeric. How can I solve? How can I define the column types of a csv file? I tried converting file in
How Create a hive external table with parquet format
I am trying to create an external table in hive with the following query in HDFS. getting error Error while compiling statement: FAILED: ParseException line 11:2 missing EOF at ‘LOCATION’ near ‘)’ What is the best way to create a HIVE external table with data stored in parquet format? …
How can I Insert multiple rows with one query
I made a code allowing me to GET data from an API and insert it into a database. But I encounter a problem my api contains about 20 million data and to insert everything in my database it will take me 43 days 🙂 I think the problem comes from the fact that I insert the data one by one.