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 last month.
Improve this question
SELECT * FROM STK_Trans
WHERE STORETO =2199 and STOREFR = 2199 and TRANSDT
BETWEEN '01/01/2023' AND '01/05/2023'
Can anyone convert this sql comment to linq?
from u in db.STK_Trans
where u.STORETO == stto &&
u.STOREFR == stid &&
(u.TRANSDT >= datefrom &&
u.TRANSDT <= dateto) select u;
I use this but not working
Something like this maybe:
var query = from u in db.STK_Trans
where u.STORETO == 2199 &&
u.STOREFR == 2199 &&
u.TRANSDT >= new DateTime(2023, 1, 1) &&
u.TRANSDT <= new DateTime(2023, 1, 5)
select u;
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 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
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)
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 7 years ago.
Improve this question
I needed some help in making sure I am using my parenthesis correctly around AND OR statements in SQL SERVER.
SELECT DISTINCT *
FROM Table
WHERE yearmonth = 201404
AND (HasA = 1 OR HasB = 1 OR hasC = 1)
AND (HasAX = 10 OR HasBX = 10 OR HasCX = 10)
When I have my parenthesis like above my second AND line of code, it also pulls out other values like example HasCX= 23.
Ironically this line of code works well:
AND (HasA = 1 OR HasB = 1 OR hasC = 1)
How should I write my parenthesis around this ?
AND (HasAX = 10 OR HasBX = 10 OR HasCX = 10)
It should only pull out data for where the condition is met with 10.
First, for your query, a cleaner way to write the logic is to use in:
SELECT DISTINCT *
FROM Table
WHERE yearmonth = 201404 AND
1 IN (HasA, HasB, HasC) AND
10 IN (HasAX, HasBX, HaxCX)
I suspect that what you really want is:
WHERE yearmonth = 201404 AND
((HasA = 1 AND HasAZ = 10) OR
(HasB = 1 AND HasBZ = 10) OR
(HasC = 1 AND HasCZ = 10)
)
Alternatively, you might want all of these connected by AND and not OR.
I think your query is right. Check your data. A row can have HasCx=23 but also have HasBX=1.