Skip to content
Advertisement

Tag: sql

PSQL stored procedures using arrays as parameter

I’m using PostgreSQL and currently creating a stored procedure to do some calculations. I’ve been searching all morning and reading the documentation, but either the functionality I want isn’t supported or I must’ve overlooked something. Basically, this is what I have: Basically what happens is that I calculate how often I need to make a travel to deliver something, which

How can I combine two columns and sort the values alphabetically?

I’m new to programming languages and am trying to get the customers with the longest and shortest names, combine them in a single column, and sort them by longest then shortest names. Here’s what I have. How can I query to get my desired result in MySQL? Table is orders customer_id longest lowest John Nathaniel John Michael Nathaniel Expected results

Is it possible to further filter on MAX results?

I have a table like so A) As you can see, the same ID can have multiple Revision IDs Now, I can grab all the latest revision for each ID by using MAX with GROUP BY like so: B) As you can see here, the Revision ID of 47141 is the latest revision for ID 3282 So here is my

Passing tuples to SQL query while unnesting

I need to query a large BigQuery table to retrieve data from certain dates about barcodes in a store. There is a specified date for each of these barcodes (there are thousands of dates for each barcode in the BigQuery table, which makes it unpractical to only query on barcode). I have therefore created a list of tuples containing the

How do I auto-increment a alphanumeric string primary key?

Let’s say I have table A with an alphanumeric string primary key. The code used to create the table and how the table looks are shown below. I want to insert a new row into Table A and I don’t want to type out C000003 or C000004 every time. Is there a way to auto increment this? I have thought

Advertisement