My table source: num_facture TYPE actif date 1 1 1 2010-01-31 00:00:00.000 2 2 1 2011-01-31 00:00:00.000 3 3 2 2012-01-31 00:00:00.000 4 4 2 2013-01-31 00:00:00.000 The Column data types are: Column Data Type TYPE tinyint Actif tinyint date datetime I’m working with SSIS to load my destination table. So…
Tag: sql
How to SUM values of a column and then order by another column using SQL?
When I SELECT * FROM table; I have the following result: So I try to sum the total of votes with SUM(votes) as tt_votes and then group the result by candidate to have a desc order. state column shows the first (or the last?) record for the candidate, but what I’d really like to have is not only group by
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
How to remove duplicated rows from table with arrays in BigQuery
there is a table in BigQuery that has REPEATED type columns and has duplicated rows, since the table has arrays I cannot use distinct to grab only one row. Table looks something like this: I want to remove the duplicated rows, the output should be like this: I didn’t find a way to come up with the above…