Questions tagged [sql]

0 votes
1 replies
A better way to group and count multiple columns SQL
I have a survey table that shows the answers that people have taken once a month when they enter a contest. I'm trying to find a better way to...
asked 4 months ago
0 votes
1 replies
ActiveRecord speed up `where.not` query
I have a query that is taking getting significantly slowed down when an not clause is added to the query. # query is 13.6ms FbGroupApplication....
asked 4 months ago
-1 votes
2 replies
How to only select the SQL row with the MAX id in this join?
I need to get the record with the MAX id from this joined table, but I only need the top row to be joined with the main query on this subquery. H...
asked 4 months ago
-1 votes
2 replies
inserting data into a table using pyodbc
im trying to insert data using python (pyodbc) into my database but i keep getting errors like missing comma and others i tried to use the varia...
asked 4 months ago
0 votes
2 replies
Trigger to prevent double bookings always flagging up
Having an issue where a trigger is always flagging up positive, even though from what I can tell it's conditions aren't being met. I want it to f...
asked 4 months ago
1 votes
1 replies
Merge two MySQL results columns where one column or the other will be not null
I would like to merge the results in column A and column B in one column, less the NULLs, where I am left with the results in column A+B. I can g...
asked 4 months ago
0 votes
2 replies
Can a table in SQL have multiple columns as foreign keys that refer only to one primary key of another table?
For instance, table Companies has columns company_name, first_contact, second_contact and table contacts have columns id(PK), name, phone. Can a...
1 votes
1 replies
Why does Microsoft SSMS syntax highlight the word “configuration”?
When using Microsoft SQL Server Management Studio 14.0.17254.0 and it's query editor, I noticed that the word configuration is always syntax high...
asked 4 months ago
0 votes
1 replies
SQL Code to display data matching on 3 conditions
Need to display the number of days elapsed of patients who were admitted to a skill nursing facility, discharged to their homes (with or without...
asked 4 months ago
1 votes
1 replies
Select one account when other accounts do not exist in Hive
I want to select accounts when other account_type do not exist in Hive I filter the records with Account_type = 'Second', but all records are...
asked 4 months ago
0 votes
1 replies
Error System.Data.SqlClient.SqlException: 'Error converting data type nvarchar to numeric.' in c#
I'm inserting data from one database table to another with a buttonclick and this error shows up System.Data.SqlClient.SqlException: 'Error conve...
asked 4 months ago
0 votes
1 replies
SQL Segmented Ranking Operation
I am willing to find the rows, which comes immediately after the (latest) row where Text = E. It is like an transaction log where I want to find...
0 votes
1 replies
Not in to not exists
I have a 'not in' that I am trying to turn into a 'not exists' within the where clause of my select I tried switching the bare minimum but nothi...
asked 4 months ago
1 votes
1 replies
Transfer Access Code into Oracle Syntax (Power Query)
I am just woorking on to transfer a Access Query into Power Query (Excel). I think there are some challenges regarding the terms/ wording. Its a...
asked 4 months ago
-2 votes
0 replies
Why do selecting specific fields from a view blow up my query?
I'm helping someone debug a legacy query that is built upon two views that each have records with the same fields from different data sources. Th...
asked 4 months ago
1 votes
2 replies
How to insert into a table where a column has a specified value
I am probably overthinking this, but how would you insert a value into a column for a table where another specified column is equal to a specifie...
asked 4 months ago
0 votes
2 replies
Cumulated sum based on condition in other column
I would like to create a view based on data in following structure: CREATE TABLE my_table ( date date, daily_cumulative_precip float4 ); IN...
0 votes
2 replies
Return results where the string in a column has a certain amount of digits [closed]
I need to create a query that will return all the results where the string in a column has more than, say, 3 digits in it? How do I go about doi...
asked 4 months ago
1 votes
1 replies
Lambda join between date range
I need to join a weekending table to a result on another table. How can I write this sql query in lambda SELECT * FROM DBS INNER JOIN WeekEndin...
asked 4 months ago
1 votes
2 replies
Get results with wildcard
I am returning @ChangeStatus variable with 'Y', 'N', Null and need to show data based on that however column has different string than variable...
asked 4 months ago
0 votes
2 replies
Laravel search for relation field value + relation field value equals field value
I am using Laravel 5.8 and I need to perform a query which searches if the value of specific field in a relation + the value of specific field in...
asked 4 months ago
0 votes
1 replies
Converting a String with Length of Time into Different DataType
I am working in sql server and have been provided with a file that has a column for "Duration" which contains string type values of length of tim...
-2 votes
2 replies
Query for getting readers who borrowed ALL books
I need to help with this problem I never experienced before. I need to get readers who borrowed ALL of the books in table Book. Thank you for yo...
asked 4 months ago
0 votes
0 replies
How two use spark.sql select two tables based on columns on every row
Basically, I have two tables, schemas given below: root |-- machine_id: string (nullable = true) |-- time_stamp: double (nullable = true) sca...
asked 4 months ago
2 votes
2 replies
SQL XML Query returning Blank value
I'm trying to setup a query to read an XML variable and it appears to be returning an empty table. The XML I am using: <collection> <...
asked 4 months ago