Tags:

Pulling different rows based on age in select query


Context I am using Oracle SQL and have data that looks like this. People are asked every year what their favorite movie is and that may update from year to year. Person Date_of_Birth …

Tags:

How to select distinct based on multiple values for one column


I feel this is a very easy task and I am grossly overthinking it. I have looked and looked nothing seems to answer my question. My question is simple, how do I select distinct on one column, based on …

Tags:

Can we use arithmetic operators (+, -. *, or /) on date functions in mysql?


I am learning mysql and I am stuck in the following question. Can we use arithmetic operators (+, -. *, or /) on date functions in mysql? Can someone help me out with it?

Tags:

SQL – Replace a particular part of column string value (between second and third slash)


In my SQLServer DB, I have a table called Documents with the following columns: ID – INT DocLocation – NTEXT DocLocation has values in following format: ‘\fileShare1234storageabxyz.ext’ Now it …

Tags:

Extremely slow “row_number() over order” query


I have a users table with columns (id, xp, …) and around 1.5 million rows. I am getting someone’s position in the XP leaderboard with the following query (which took 33 seconds to execute): EXPLAIN …

Tags:

Chinese characters in Access SQL Query


After populating the recordsource the next action is clicking on one of the fields populated to “activate” the record. When clicking this, the goal is that the SEC_ID (A GUID, Number Data …

Tags:

Extracting date in SQL


I have a column due date in the format 20210701 (YYYYMMDD), using SQL I want to extract all the dates apart from 5th of particular month ( As highlighted in the pic below ) I used the below code: …

Tags:

Building and Grouping JSON Object in SQL Server


I have the following table and I’m trying to combine the rows into JSON objects. Username AccessKeys Marker user1 {“Account”:”1″,”Checking”:”0001″,”Loan&…

Tags:

IBM Cognos Analytics Selecting top 2 from a dataset


I’m working on a report where I need data for current week, and the week before, and compare these two. I have a week column in my data, which are transactions, So my data looks something like: Amount …

Tags:

Why are my Hibernate `select` queries super slow?


I am using Hibernate in my Java based REST API. I am using HQL mainly because it is easy. Also for this project, I am loading data from the main table, its associated tables, their associated tables …