Skip to content
Advertisement

Tag: sql

Get distinct members for an array of group IDs

I have 3 tables: Scorecard Group Scorecard_Group (Joint table) I am trying to write a query that fulfills the following purpose: Get the list of distinct scorecard ids WHERE Scorecard_Group.groupId IN (Pass array of groupIds) Get all Scorecard.”name” where Scorecard.”id” IN (Array of scorecardIds that we just queries) I am able to achieve this using 2 queries but I would

Parse utm parameters in sql query

I have a table in my database that tracks visitors page views and I am trying to pull out the utm tracking parameters from the url You can use this script to create table This my script I am getting funny results where if there is no utm tracking it is still populating fields and the utm_id is incorrect in

SQL: date type column with only mm-dd

I want to create a column of data type having only ‘mm-dd’ values. Is it possible and if yes how should I do it? Note: Instead of “2022-06-07”, I want “07-06” Answer There is no date type that can store that format – in fact none of the date types store a date and/or time in any of the formats

How to extract value from middle of substring in SQL?

I have column called “CustomerId” with value “1_Nissan_028” and “2_Ferrari_035”. I would like to extract “Nissan” or “Ferrari” as “CustomerName”. CustomerName is located in middle of CustomerId and lenght varies. Following SQL query return values like “Nissan_” or “Ferrar”. How to write SQL statement? Answer Assuming that the value is always the 2nd delimited value, you can use STRING_SPLIT and

PostgreSQL – Adding up json values

This is my json column in pgSQL and I need to add up all of the “sum” amounts using pgSQL. So the query should return “50” using the data below. I did find something like this (Get aggregate sum of json array in Postgres NOSQL json data) that kinda works if I had my values in array, but I dont,

Implement Scan and Value functions in golang

I am trying to store some golang objects in SQL database and have implemented the scanner and value interface as follows: Is there a way that I can pass the parameter to the Value() function by pointers, as I am getting a HugeParam error that the attr passed to the Value() function is too big, when trying to convert the

Advertisement