I am facing a challenge in SQL. I have the following query: SELECT * FROM Books WHERE Categories IN (‘Fiction’, ‘art’) OR Language IN (‘en’, ‘de’) OR Country = ‘DE’ I need to look at …
sqlite return same value on left join
in below my sqlite command i want to get count of barcoeds when that’s equals with sessions.id select sessions.id, sessions.session_name, sessions.session_type,sessions.date_time, count(barcodes.id) …
SQL Function: Get next value in row
I’m looking for an SQL way to get the value from the next row. The data I have looks like: CURR_STRT_DT CUUR_END_DT product 6/30/2019 9/28/2019 A 6/30/2019 9/28/…
float to string no scientific notation: SQL Server
Have a problem with some wonky ID’s that I can’t quite figure out. The above is a result of joining two tables, where ID1 = ID2. ID1 cannot be null, however ID2 can be null. What I’m attempting to arrive at is: So I can then drop the other column. I’ve tried casting, str function, remo…
How to get particular object from jsonb in PostgreSQL?
I have a table called ‘Test’ that holds two fields ‘qnId’ and ‘Answers’. ‘qnId’ stores a uuid and ‘Answers’ is a jsonb array that roughly looks like this: [{ “user” : “1”, “ans” : “some text” }, { ̶…
SQL server error in regards to common table expression [closed]
I have this query: if object_id(‘tempdb..#mappings’) is not null drop table #mappings; Create table #mappings ( GLEntity int, NoteOwner VARCHAR(MAX) ) INSERT INTO #mappings VALUES(351, ‘Ajax …
Error when using function: The used SELECT statements have a different number of columns
In my MySQL database I have defined a function called isUserVerified that return the status of a user. I am trying to use the function in a SQL statement: SELECT id, isUserVerified(id) AS …
SQL concat case select when trying to add new column of previous month data
I have a data set in which I need to concat month and year for the previous month. the problem is it spans over two years. I need to create a statement in which mean the month – 1 = 0, month becomes …
How to pivot time series table without aggregation
I am pulling sensor data from a Teradata table for analysis. Below is what the table looks like. I want to pivot it such that sensor names become columns. There are more than a hundred sensors and …
Sql query to flter by column only if duplicate exists
I’m writing a query on data with a ‘provider_id’ column. The data is mostly unique except for some entries with all columns but ‘provider_id’ being unique. Most of the values for provider_id are 1 but …