I have been searching the forum and found a single post that is a little smilair to my problem here: Calculate average for Top n combined with SQL Group By. My situation is: I have a table tblWEIGHT …
How to select row values conditionally and change them to custom columns?
I have two tables orders, product_meta that are as follows: orders: order_id product_id 1 45 1 46 2 46 product_meta: product_id meta_key meta_value 45 price …
Adding a conditioned extra field to a query result
I have these two tables TABLE 1 ( tournaments_data ) tournament_id | accound_id | data1 | data2 TABLE 2 ( tournaments_subscriptions ) tournament_id | account_id Here, i have to read data of table 1 …
postgres12 alter table with type cast syntax error
I’m trying to alter a table with values like below. The data type is a string but I want to change it to numbers. ALTER TABLE data ALTER COLUMN value TYPE NUMERIC(7,2) USING value::numeric ERROR: …
Concatenate and add a character to integer columns in SQL
I have a 10 Character length values in a column in SQL Server. I need to split that column at fixed length and remove the leading zeros and add a – after each of the values. I am able to split the …
Query updated records in Database
Currently all our tables have a created_at and updated_at timestamp, e.g. The updated_at field is modified with every INSERT. This allows us to query all Cart’s which have been updated since a particular point in time with something like this: However this would not capture updates to FK relationships s…
Possible memory leak in simple batch file processing function in c#
I’m running a very simple function that reads lines from a text file in batches. Each line contains an sql query so the function grabs a specified number of queries, executes them against the SQL database, then grabs the next batch of queries until the entire file is read. The problem is that over time …
Combining MySQL Queries to get total amount
I’m trying to combine the following 2 queries. table_A stores a list of available appointments and number_open is how many open slots there are for a specific appointment, in this case 2020-06-30 AM which has 5 open. table_B contains any dates waiting to be accepted and has a different record for each d…
Grouping together results of multiple GROUP_CONCAT() with distinct values only
second attempt at this question with more detail. I am attempting to group the distinct values of multiple columns together for objects of the same name. I can use GROUP_CONCAT on each of the ‘Type’ columns, but I can’t merge them together to get a distinct set of values for each name Here i…
Extra null rows when using LEFT OUTER JOIN
I have three tables SpringCount, SpringObservation, and MonitoringPoint. SpringCount and SpringObservation particpate in a one to many relationship. Some counts have no bird observations, some counts do. I want to return a table with all the counts represented and nulls in the appropriate fields when they don…