I would like to write a query to compare created_at timestamp with my current date in Ruby on Rails using ActiveRecord and I don’t quite know how do it yet Date is stored like this -> created_at: …
Oracle SQL – return the date record when there is no count result
I have the tables below and I need my query to bring me the amount of operations grouped by date. For the dates on which there will be no operations, I need to return the date anyway with the zero …
Why does the table randomly reorganize the rows?
I have the following table DBName Server Status UpdateTime DB1 server1 NULL 5/4/2019 DB1 server1 NULL NULL DB2 server2 NULL 6/4/2019 DB2 server2 NULL 6/4/2019 DB3 server2 NULL NULL …
How to pick data of the same IDs without repetition
How do I pick data of same IDs without any repetition? DECLARE @YourTable TABLE (ID INT, NAME VARCHAR(100)) INSERT INTO @YourTable SELECT 123, ‘James Hill’ INSERT INTO @YourTable SELECT 123, ‘Hill, …
How to show 5 maximum value after joining two tables?
I have 2 tables: users(uid, rollno, name) results(rid, uid, marks) So I want to show the highest 5 marks holder with their roll no and marks like- MCA-03/17 16 MCA-01/17 15 MCA-04/17 8 MCA-…
Join repeatedly until a string is present?
While querying a subset of our employees, I’m trying to add a field for the SVP they “roll up” to. Employees may have anywhere from 1 to 5 or 6 degrees of separation from their SVP. The trouble is, …
RANK() function with over is creating ranks dynamically for every run
I am creating ranks for partitions of my table. Partitions are performed by name column with ordered by its transaction value. While I am generating these partitions and checking count for each of the …
How can I “Update Select” some values in a column with a subquery?
I am using Apache Derby DB (SQL) version 10.14 and this is the Derby Reference Manual: https://db.apache.org/derby/docs/10.14/ref/refderby.pdf I am trying to create a star schema and am currently …
MySQL output gives values from different rows
I am working on sql and there are 4 different columns which are pname, Fname,Flastname and amount. It gives the correct outputs for pname and amount but fname and flastname are from different rows …
SQL Query doesn’t run as intended(between)
I have the following query(in postgresql), select distinct “bookings”.”memberId” from “shifts” inner join “bookings” on “bookings”.”shiftId” = “shifts”.”id” where “shifts”.”startTime” not &#…