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
Related
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
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?
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'
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 9 years ago.
Improve this question
I'm stuck at one of my homework assignment.
The question was:
Which l.levcode's are not in b.levcode's?
This is how far I got:
SELECT l.levcode, levnaam, levadres, levwoonplaats
from leverancier l, bestelling b
where l.levcode = b.levcode
but now I don't have a clue what to do.
try this code:
SELECT l.levcode, levnaam, levadres, levwoonplaats
from leverancier l
where l.levcode not in
(select levcode from bestelling)
You can simply use NOT IN
SELECT l.levcode,
levnaam,
levadres,
levwoonplaats
FROM leverancier l
WHERE l.levcode NOT IN (SELECT b.levcode
FROM bestelling b)
I think this should work:
SELECT l.levcode, levnaam, levadres, levwoonplaats from leverancier l, bestelling b where l.levcode NOT IN (select levcode from bestelling );
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 9 years ago.
Improve this question
I have 3 tables:
user(use_id, use_role),
message(mes_id, from_use_id[fk->user.use_id], mes_create_at),
message_user(mes_use_id, mes_id[fk->message.mes_id], to_use_id[fk->user.use_id])
User can be use_role=1(student) or use_role=2(teacher).
I have to get all Users that are use_type=1(student) sorted by last contact with teacher. No matter if student write to teacher or teacher write to student.
I assume you use ms sql:
select *
from
(
select student.use_id, Message.mes_create_at, Message.from_use_id, Message_User.to_use_id
from User student
join Message on Message.use_id = student.use_id and student.use_role = 1
join Message_User on Message_User.mes_id = Message.mes_id
where Message_User.to_use_id in (select use_id from User where use_role = 2)
union
select Message_User.to_use_id, Message.mes_create_at, Message.from_use_id, Message_User.to_use_id
from User teacher
join Message on Message.use_id = teacher.use_id and teacher.use_role = 2
join Message_User on Message_User.mes_id = Message.mes_id
where Message_User.to_use_id in (select use_id from User where use_role = 1)
) as temp
order by mes_create_at desc