Skip to content

Tag: sql

force query to return duplicate values sql oracle

i have a simple query so when this query runs and returns output it only shows 3 rows but i want the output to be repeated like below is there a way i can achieve this Answer Pass in a collection rather than using an IN filter: Which, for the sample data: Outputs: NO SURNAME GENDER 123 m m 456

Difference between count(*) and count(true) in sql?

what is the difference between the select count(*) and select count(true)? so is there any different between the count(*) and count(true) which one should I use? can you give me situation example for each one that is better option to choose? Answer The result of both is the same, but count(*) is slightly fast…

SQL or function

In SQl its common to take the SUM of all values from a column Can the same thing be done but instead of summing each value in an attribute, each value is “OR’d” together? This would only work if the attribute was boolean of course Answer MAX(booleancolumn) will return OR’d together. (S…

SQL for finding multiple column matches (dups)

I’m trying to write a query to find all rows that have three columns in common with other rows. Imagine a person can only send one letter to another per day and I need to identify “dups” even though all of the columns may not be the same. I want to see all rows that have the same Sender_ID A…

Convert week number and year to a date in Access-SQL?

In Microsoft Access, I have a table where number of hours worked per weekday are associated to a project number, ISO-week number and year. Simplified, it looks like this: ProjectID WeekNumber YearNumber Monday Tuesday 1 1 2022 5 6 1 2 2022 7 8 I am trying to set up a query where all weekday columns (monday to…

Three-table join with NO EXISTS

I have three tables and would like to answer the following question in SQL: “Who has only certifications that do NOT have scores?” For instance, in the setup below, the query would return “John” only. Joana has the “AWS Certification”, which is in SCORE table (id 57). Marry…

T-SQL : Alter Database statement inside IF is failing

We have a scenario where we have to change database compatibility based on SQL Server version and we have written below condition for the same. In one of our customer’s server this code is failing with below error and the server has SQL Server 2014 Msg 15048, Level 16, State 1, Line 4 Valid values of th…