I am using SQL Server 2012. I have data in a SQL Server database in the same table that needs to be brought into multiple columns. I have two tables, tblIVContent: and TBLIVTextData: In order for a …
COUNT Multiple Columns using GROUP BY – SQL
I am trying to create a GROUP BY COUNT of ~30 columns in my database. The database is basically a shiftplan, where on each column a row can be assigned different shift types (denoted as a D, N, A, X, F, C, etc..). I can use the following query to get a count of each shift type, am struggling to
SQL Join – Limit to base table
I have 4 tables that I want to link together based on the information in the sales_details table which will serve as the base table (limiting results based on the sales_details table) 1)I want to pull all columns from the sales_detail table that are mastercard orders but since the sales_detail table doesnR…
SQL – Find most recent value from other fields (per user, between occurrences)
I have actions and results mixed together in an “event” field. But each of these actions essentially “causes” the result (and the subsequent outcome) (let’s assume). I want to tie each future outcome back to the actions that caused it, for each user. I want the value from the …
‘cannot extract element from a scalar’ when order by id is DESC
I have a PostgreSQL 9.3.10 database, a table with 15842 records and use Intellij for making queries. I want to query some recent data from JSON column (named ‘data’). My query is that simple: The problem is that I get: [22023] ERROR: cannot extract element from a scalar when I use desc order. When…
How inaccurate can the sys.dm_db_partition_stats.row_count be in getting an Azure SQL DB row count for each table?
I have seen a number of general statements on how sys.dm_db_partition_stats.row_count can produce inaccurate results due to providing objects’ statistics instead of actually doing a COUNT(). However, …
SQL query to get the first letter of each word and seperate it by a dot and a space
I have never really used SQL much but recent changes due to working from home is forcing me to gain some knowledge in it. I have been doing fine so far but I am now running into a problem that I can’t …
How to filter within a Window Function PostgreSQL
I only want to filter in Window function to keep the created_at is null so I don’t use WHERE clause previously. Because when I order by created_at desc it will show the null value first. How to add a …
sequelize updating multiple rows
Update multiple rows , is using a bulk update a good solution or something like the code below works ? . I supposed wanted to update all the records with the id and filename. I did try to update …
how to resolve data type incompatability issue in SQL server
I have been trying to build below logic Declare @OT float Declare @Remark varchar(100) set @OT = 9.52 set @Remark = ‘1-25 hours’ select case when @Remark=’1-25 hours’ then (FLOOR((@OT * 100)/100)*…