I am trying to extract the hour from a timestamp with a timezone. However, my times are coming up incorrectly. Here’s an example, I am using Dbeaver with my timezone set to EST: SELECT ‘2020-01-24 …
I have a trigger on my SQL Server table which takes user updates and log them, in case we need to revert, but it has a problem
The problem is, sometimes in a day that no one is changing anything, a random user just enter the page and the trigger saves a change. The problem is, not only it logs a change that never has occurred …
Creating a table with 2 primary keys and two foreign keys referring to 2 different tables with same constraint name
For this particular schema: I have created the department student and subject tables now the problem right now arises in the creation of the mark table. It is specified that there are 2 primary keys …
How can I efficiently paginate the results of a complex SQL query?
I have a fairly complex SQL query which first fetches some data into a CTE and then performs several self-joins on the CTE in order to compute a value. Here’s an abberivated exmaple, with some complexities of our application simplified: The query is auto-generated and can scale to a complex computation …
Can’t run two .sql in a single .bat file
I have a scheduled task with a .bat file that downloads some files from a web server every day by the morning then process the data and UPDATES a database. Then it triggers another .bat file to SELECT …
SQL Count columns from other columns
I have this view generated after using LEFT JOIN over 2 tables (simplified example). Tables: T1: Id, …other columns not used +—-+—–+ | Id | … | +—-+—–+ | 1 | … | | 2 | … | +—-+-…
SQL SERVER PIVOT like PEPSI comes under year then by months etc.. (refer attached image for a clear idea)
I am new to PIVOT… so i dont know whether is it possible or not with pivot. Here is the table and the sample data i used create table sales_history (brandcode varchar(10) , …
postgres unable to get query filter by time and date viz
I have data like this:- select id,created_at from tickets where created_at between ‘2020-01-23’ and ‘2020-01-25’; id | created_at —–+—————————- 297 | 2020-01-…
Fetch Substring in Oracle
I have a string as – V_TAG_B = utm_source=google_search&utm_medium=cpc&utm_term={Keyword}&utm_campaign=home-|-SBI-|-search I need to break this string into 4 small parts as – I need to do this because the string can be in any order such as utm_campaign coming first and utm_source is co…
Significant delay in generation of View (Viewed Table) in SQL Server
I have a few Personnel Details tables in a database in SQL Server 2014. There is a view that pick up selected data from these tables by implementing a few joins. One condition to select the row is if its columnn isActive = 1 in NominalRoll table. There is a report in SQL Server Reporting Server that calls thi…