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 …
Tag: sql
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 …
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) , …
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…
Postgres LEFT JOIN not returning nulls?
Not sure why this is happening, but I have this query: And the item table has 100 elements. I’m looking for the resulting rows to be grouped by user_id and have each array be 100 items long. That is, if the value is not present in the vote table, to just instead sub in a 0 in its place. Unfortunately
how to display data on 2 different date ranges
I have the following date data, which is used to display MySQL data parameters and I have the following query: The result I want is that the program will display data from date :$tgaw to date: $tgak Answer You should be using prepared statements here, and also use the MySQL functions to add one month to the u…