Category "sql"

Using Distinct in Aggregate Select query

I am using oracle DB. I have a Aggregated script. We found that some of the rows in the table are repeated, unwanted and hence, is not supposed to be added in

How to Check Which Record is non-numeric in a String Column in Delta Table

I am working on Delta table using Databricks on Azure. The Delta table contains about 100 million records with many columns. One column data type of which is S

How to get distinct value and specific count from a query

Suppose I have the following table "Person": id name friends 1 matt jim 1 matt ray 1 matt ray 2 tim fry 3 sally jack 3 sally tim 4 matt harold I want to outpu

EF Core one-one relationships

I need to configure following one-one relationship with ef-core public class Player { public long Id { get; set; } public string Name { get; set; }

OTBI analytic to function value is not null in any one of the columns for a particular employee

My OTBI(Oracle Transactional Bi report) report have the following columns - Person number Date_to Person Name comp Specialization

particular column has multiple data separated with comma, how to write a query to return that particular row if it has at least one data

For example col1 col2 1 2,3,4 Referring to the table shown here, if I want to return a row if col1=1 and col2 has 2,3. How to write query for this scenario? B

JPA Specification predicate for querying latest/newest/most recent records

I'm trying to convert the below query into a JPA specification in order to enable more flexible querying of my Rule entities, but i don't find any way of transl

How to check if SQLAlwaysON is existing in server using powershell without a SQL DBA Admin access?

I want to check if SQLAlwaysON exists in server. I already know that typing and getting the powershell commands Enable-SQLServerAlwaysON and Disabled-SQLServerA

Snowflake. How to check if the sub-array is presented in another array?

I want to check if all the items from one array are presented in another array. I've been looking through Snowflake docs but can't find any good approach. For e

How to calculate frequency percentages for a table using SQL?

Let's say I have some data as follows: ID data fingers rating 001 hello y 0 002 hello n 0 003 bye n 0 004 hell

How to I order by a sql table multiple times?

I don't think I worded it correctly but how do I use order by to sort a table multiple times by a different dimension. For example if I wanted to sort by type o

Two-part conditional sql statement

The statement below is querying a log table and I'm trying to get the max budget depending on the scenario if falls within. Error message: Expressions referenc

Two conditions in where tag of Liquibase

I want to add two conditions in where tag of liquibase and exception is thrown: Reason: liquibase.exception.DatabaseException: Unknown column 'uid' in 'where cl

return the row where before and after value is lower

I have a table that looks like this: name val 1 1 2 2 3 1 4 2 5 2 6 10 For each row,

How to update the timeout field in the attendance table for a given user_id, logdate and status using if else statement?

I have been trying to update the timeout for a given user_id, logdate, and status but my update statement is not working or may be my other if else are not corr

Error with creating a laravel foreign key

I'm trying to create a relational database and this is the error i get SQLSTATE[HY000]: General error: 1005 Can't create table somedumbtable.meals (errno: 150

Select item that is different in each of group by a column

I have this sample table +--------+-------------+ | DBName | Description | +--------+-------------+ | A | Car | | A | Boat | | B

django annotate whether exists or not

I have a query I'm using: people = Person.objects.all().annotate(num_pets=Count('pets')) for p in people: print(p.name, p.num_pets == 0) (Pet is ManyToO

get the most common value for each column

I'm attempting to create an SQL query that retrieves the total_cost for every row in a table. Alongside that, I also need to collect the most dominant value for

Check if a number is prime or not in mysql

I am wondering what's the best way to check whether a number is prime or not using sql. I was able to generate the sequence of numbers from 1 to 1000 but I woul