I am using Crystal Reports to pull data from DB2 10.5. I need to calculate a specific date and then use this calculated date as a filter. Here is an example of how I am currently achieving this. WITH …
SQL Select in an Insert statement
How can I combine these two scripts? I basically don’t want to hard code the number 34 in Query 2. I want the script to take the next number of job_id. Query 1 returns 34, so Query 2 should take 35 as …
How to calculate difference between 2 time columns in distinct tables?
I need to calculate the difference between EntryHourSchedule (the ideal time) and EntryHourRegistered (the real time) of a worker’s assitance, but both are in 2 different tables: ScheduleDetail (* to …
How to fix Nested CASE Syntax Error “Invalid Number of Arguments” in Oracle SQL
Im running a query in Oracle and am trying to create a new column that is defined by the nested CASE statement below. I get an error on the highlighted “Else” statement saying “Invalid Number of …
SQL refer Primary Key in same Table and Query
I am maintaining a table of Items (Id is Primary Key). Some Items have Parent Item ( Which is also an Item, the colum Parent holds the Id of the parent Item, which is also in the same table. Some …
With CTE, compare rows with same ID and updating oldest one to 0 SQL Server 2008
Asked for the logic yesterday, now I’ve worked a way around. I have a big table used for reporting (170k~ rows) and many of them are “duplicated” but with updated dates (e.g. old record says John Doe …
Use time selector from Power BI as an argument in my SQL query
I have a simple query like : SELECT COUNT(DISTINCT(p.id_organization)) AS Count FROM dbo.paiement p WHERE p.statut = ‘AUTHORIZED’ AND p.[date] > ‘2018-01-30’ I try to show this data on a …
Count as duplicates similar values
I have following tables: Orders order_id 9 10 11 Order_details order_id, product_id 9, 7 10, 5 10, 6 11, 6 11, …
how to compute percentage in mysql/sql when 2 group by conditions are present
id title count organizer 1 music 4 2 2 sports 6 2 3 music 2 3 I have a derived table with the above structure. I need to compute the percentage of the number of events of each …
how to fetch data from two tables in JPA
I am not able to fetch all records from two tables using the below query I have tried this but I am getting a result from one table only. I want a result of both the tables i.e, …