I am trying to turn select into function, but keep getting error: “query has no destination for result data”. Select returns 5 columns so I am trying to return table with 5 columns. I can not figure out what I am missing, please help! Answer As the error message suggests, you have to tell the func…
Tag: sql
MySQL – Query and group in a single row
I have a set of data as below: EmployeeId Salary_Basic Salary_Transport Year E001 12000 3000 2018 E002 9000 2000 2018 E001 13000 3200 2019 E002 10000 2400 2019 E003 15000 5000 2019 What I want is below: EmployeeID NetSalary_Year2018 NetSalary_Year2019 E001 15000 16200 E002 11000 12400 E003 0 20000 Can anyone …
SQL statement throws “dpiStmt_execute: ORA-01821: date format not recognized”
I am doing an SQL exercise, where I have to determine the amount of returned films to the film store at the given date “2005.06.05” and the number of films, which were borrowed at this date. Somehow I always get the errow message standing in the title. Does someone know how, where I made the mista…
SQL query – not null
I have sql query: I got this table id position10 position20 position30 1 2021-05-02 2021-05-02 2021-05-3 2 2021-05-15 2021-05-16 2021-05-18 3 2021-07-08 NULL NULL And I want lines where NULL values are not picked up. A try this: But it still chooses to me where the NULL value appears somewhere. Answer You nee…
Getting the correct data to be stored into temp table by comparing timerange
Currently, I need to get the correct data to be inputted into temp table. There are 3 datetimes that I need to compare. However not all values are populated. Example-Assume that all dates are the same Data1 DateTime1 DateTime2 DateTime3 First 2020-08-24 14:00:00.000 2020-08-24 14:30:00.000 2020-08-24 15:30:00…
How to get in json a column that combine from two field in sql?
I have table with those columns in mssql: How to combine name and surname into info when I get json from the sql: What I get is: And what I need is: This is possible to do with mssql? if so, how can I do it in sql? Answer You need to use FOR JSON PATH to build the nested
What is the fastest way to look up continuous data on Anylogic (Java, SQL)
I have a database table of 900,000 rows. This table contains power, braking power, speed log from train trips as a function of distance. Origin Destination Distance travelled from departing point Power reading in MW Braking power reading in MW Speed reading in KPH There are 13 different destinations and outbo…
Select rowst where ID is on list and meet 2 other requirement, probably subquery in Teradata SQL?
I have table in Teradata SQL like below: And I have list of ID of clients: And I need to select ID of clients from table which are on myList and meet requirements: In col1 value is “A” or “B” In col2 value is bigger than 10 (>10) So as a result I need like below: Because ID = 111
Sequelize – is it possible to limit the number of record in junction table
There are 3 tables student_teacher, student, teacher with below relationship. Each teacher will be responsible for 5 students, so the relationship should be 1 to Many, but I decide to create a junction table for storing extra information for this relationship. When I create a student_teacher record, the paylo…
How can I change vartypes of a SQL table from R using ODBC package?
This works, however I want to change the sepal.width to decimal(28,0). Is it possible to do it before writing to SQL, or can I modify the SQL table to change the column type from R? I know I can use RODBC, but I am forced to use R Version 3.6, so it is not an option. Answer Look for field.types