For a given feature (line or area) and for all of its members I need to extract the coordinates of (1) all the vertices, (2) the first vertex and (3) the last vertex (3 separate queries to create 3 …
Tag: sql
Ordering records by an association presence
Lets say I have an instructions table which is associated to a surveys table through survey_instructions join table. What I need to achieve is to fetch all instruction records, but ordered by an …
Find How many minutes a month has: MySQL
Say I have a column Date 23-03-2019 04-04-2019 I want to find hoe many minutes the whole month has in MySQL. Expected output: Date MinsinMonth 23-03-2019 44640 04-04-2019 …
Count the number of records in SQL results before a certain value is reached
Looking to count the number of SQL records until a certain value in one of the table columns is reached. Using Asp /VBscript. Not sure how to formulate the query. What I’ve tried is but of course it …
Select first 10 rows of a column in a table
Can you please let me know how to select first 10 rows for every cusip in the below table SELECT [dt_dim_id], [cusip_num], sr.[product_dim_id], [acct_dim_id], […
SQL many to many
I have fivetables here: User +——–+———-+ | stu_id | batch-id | +——–+———-+ | 1 | 1 | | 2 | 1 | | 3 | 1 | +——–+———-+ subject_id +-…
Unterminated dollar quote
How to use IF statement in the PostgreSql (11 version)? I tried just raw IF usage but got problem (syntax error at or near “IF”). To resolve this problem people propose to use ‘do &&’ but it does not work as well (Unterminated dollar quote started at position 3 in SQL DO $$ BEGIN IF ……
Is there any way to insert below nested json data into sql server
I am working on a nested JSON data which I need to load into SQL SERVER 2012. The nested JSON contains two roots i.e. one column and another rows. I need to put value from row into the column. Please …
set Monday is first day of week
I’m using Microsoft sql server and in the sql server by default first day of week is Sunday but I need to set it Monday is the first day of week.
Count sum of two columns
I am trying to count the sum of 2 columns from a subset of results, so far I have put this together SELECT COUNT(*) FROM table_name WHERE column_1 + column_2 >= 3 IN (SELECT id …