Skip to content

Tag: sql

SQL Server – Concatenate – Stuff doesn’t work

I have this query in SQL Server and I want to concatenate using stuff the ‘Products’ column, but I don’t know why this doesn’t work… And the result is: And I want this: Also I used SELECT DISTINCT in the query but the result is the same… So, where can be the mistake? Answer…

Selecting Rows That Have One Value but Not Another

I need a get some rows of two tables with join that shoud have one value in a column (1407) but shouldn’t have other value (1403) These is the tables and the query: I need: Because MAM have both codes (1047 and 1043). Answer To rephrase, I think you mean “I want to return matching rows that have e…

How to SUM multiple fields with condition

Here is my table structure the thing is, i want to SUM field (col1,col2,col3,col4) but only the value 1. so based on the record above. the result would be 3 (col1+col2+col4), becauser value from col3 is 2 not 1. sorry for bad grammar. Answer Either you mean: You want to calculate a new column on each row whic…

Select row where latest quarter and year In POSTGRESQL

I need help with my issue here . I need to select rows where quarter and year are latest . Here is example of my table Risk Master table named HD_Risk_Master:- Another table that join with HD_Risk_Master table named HD_Case_Resolution 1:M Expected Result My result of query , no HDS-OP3 and HDS-OP4 in my query…

utilize ident_current in JSON insert

Is it possible to merge / mix / join the SQL command IDENT_CURRENT(‘table_name’) with a OPENJSON insert statement? For example a table dbo.properties contains: id as int (primary key, auto increment) objectId as int property as varchar(50) value as varchar (50) I fill the property and value based …

Oracle SQL Count function

I am hoping someone can advise on the below please? I have some code (below), it is pulling the data I need with no issues. I have been trying (in vain) to add a COUNT function in here somewhere. The output I am looking for would be a count of how many orders are assigned to each agent. I tried

mysql: Select Max value and delete other rows

I need to get the row with the maximum status value for each employee_id and keep only one record for employee_id If status is equal for the same employee id then pick one and delete the other, Thank you and appreciated Table: ID Type Status emplyee_ID 1111 A 0 10 2222 A 1 10 3333 B 0 20 4444 B