i am a beginner in database programming. I am doing my homework, and i get a task about sql queries. My task is to merge 3 columns(first name, last name, sex) of a table(person) in a sentence. for …
Tag: select
Update table using select and where
I have two tables: table ficha_atendimento int id string cidadaos_cns table cidadaos int id string cns I need do create a column int cidadaos_id on table ficha_atendimento_cidadao and I like to …
Getting Distinct Id(FK) by the latest date in SQL Server
I’m currently working on a query where I need to distinct ID based on the latest date created. Here is my diagram | ID | ModelID | LocationId | DateCreated | |——+—————-…
Extract a specific value from a string in a column
Need help with a situation, I need to extract a specific value from a column containing string. The string varies over different records, but the value I need to extract is always preceded by the word “VERSION” I tried to user REVERSE & SUBSTRING but not able to get exact results. Any help wil…
Duplication of results after selecting data from two tables with the same values
Good day! I’m having a problem in duplication of results when I’m selecting data from two tables with the same values. I have one data in my first table homepost with an ID of 2 and I have three data …
Why I’m getting ORA-00979 while trying to use LISTAGG and LEFT JOIN?
I’m trying to group my results so, instead of looking like this: id | nome | bairro ——————— 1 . |Test 1 | bairro 1 1 . |Test 1 | bairro 2 2 . |Test 2 | bairro 3 It looks like this: …
Count as duplicates similar values
I have following tables: Orders order_id 9 10 11 Order_details order_id, product_id 9, 7 10, 5 10, 6 11, 6 11, …
One select statement with multiple Group BY on the same column
I have ‘TABLE_A’ like this: TVA Amount InvoiceID ———————- 22 | 10.00 | inv-12 22 |-14.00 | inv-13 25 | 24.00 | inv-14 25 |-36.00 | inv-15 25 |-25.00 | inv-16 25 | 18.50 | inv-…
How to select list of rooms containing all items from a list?
I have a table items_in_room that links which item is in which room (columns are room_id and item_id). Is there a way to select all rooms that contain all items from the list? I’m aware that …
SQL Server: remove duplicates in exchangeable columns
I have this query: select OSFES97.CodeId, OSFBA97.CodeId, OSFES97.ReceiveDate from StockArchives OSFES97 inner join StockArchives OSFBA97 on OSFBA97.ReceiveDate = OSFES97.ReceiveDate …