How to classify a set of rows in SQL? [closed] - sql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 months ago.
Improve this question
I am trying to solve this SQL exercise. But I do not have any idea how to do it. Do someone have a good idea?
Try it out: https://dbfiddle.uk/fQmZkOaw

Something like:
SELECT workflow
, case when min(status) = max(status) THEN min(status) -- if all status is same, set to status
when min(case when status = 'Error' then 0 end) = 0 then 'Intederminate' -- if any status is error then intedermined
else 'Running' end
FROM #ProcessLog
group by workflow
mayhaps?

Related

How to solve SSIS logic I want to build in stored procedure [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
truncate table fact_ar_work_01
========>>>>>
select as_on_date from cmn_topic where area='AR'
SQL - Delete data from Fact_AR_open for as_on_date
loop
#V_Counter=#rollingmonth
Delete from fact_AR_open where EOMONTH[as_on_date] = EOMONTH[as_on_date]
delete from fact_AR_open where convert(smalldatetime,as_on_date ) >=convert(date,? ) and as_on_date <=convert(date,?)
begin transaction
select CASE WHEN 0 = 0 THEN (select as_on_date from cmn_topic where area='AR')
ELSE DATEADD(dd,-day(dateadd(mm,0, (select as_on_date from cmn_topic where area='AR') )),
DATEADD(mm,1 - 0, (select as_on_date from cmn_topic where area='AR') )) END as as_on_date
I want this in cursor how i write all this in cursor

Multi Column Set Null Value [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have the following SQL Statement, which gives me an error.
UPDATE GNGRB.BS_CLOSING
SET ENDINGDATE + STATUS + STATUSDATE = NULL
WHERE UNIT = '231296' AND BMON = '2020114';
What is wrong with that code?
You can update multiple columns like that:
UPDATE GNGRB.BS_CLOSING
SET ENDINGDATE = NULL
,STATUS = NULL
,STATUSDATE = NULL
WHERE UNIT = '231296'
AND BMON = '2020114';

Case when Parent SpecID is Same as Child SpecID [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to know record where ParentSpecID = to ChildSpecID cannot think of how to approach
It seems very simple using inner join, if I followed you correctly.
Select p.*, c.*
From parentspecid p
Join itemspecfullstruc i on i.rootitemspecid = p.itemspecid
Join childspecid c on i.childitemspecid = c.itemspecid
Where p.itemspecid = c.itemspecid

SQL Query for the condition 0 AND 0 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have 2 tables in Database
I want to fetch the records except (sales=0 && quantity-0) from sales table and (stock=0 && quantity=0) from stock table.
Using the select query with different conditions are not giving the required result.
I want the selected result
You need OR between condition of the same table as follows:
(s.sale <> 0 OR s.quantity <> 0) AND (st.stock <> 0 OR st.quantity <> 0)
You can also use the NOT as follows:
not (s.sale = 0 and s.quantity = 0) AND not (st.stock = 0 and st.quantity = 0)

SQL query for overlapping time [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have this data:
I'm looking for a query which can return the results of combination of Type (Phone and Memory) based on overlapping of startdate and enddate as below:
Thanks
Probably something like this:
SELECT *
FROM
table p
INNER JOIN
table m
ON
NOT(m.startdate > p.enddate OR m.enddate < p.startdate)
WHERE
p.Type = 'Phone' AND
m.Type = 'Memory'