I have this select Case SQL statement which compute the totalvolume of a given quantity.
SELECT
DropshipPackinglist.CaseNumber as 'CASE NO.',
DropshipPackinglist.ItemNumber as 'BOM NO.',
DropshipPackinglist.Quantity as 'QTY',
CASE
WHEN DropshipPackinglist.Quantity >=31 and DropshipPackinglist.Quantity <= 36 then '1090x730x1460'
WHEN DropshipPackinglist.Quantity >=25 and DropshipPackinglist.Quantity <= 30 then '1090x730x1230'
WHEN DropshipPackinglist.Quantity >=19 and DropshipPackinglist.Quantity <= 24 then '1090x730x1000'
WHEN DropshipPackinglist.Quantity >=13 and DropshipPackinglist.Quantity <= 18 then '1090x720x790'
WHEN DropshipPackinglist.Quantity >=7 and DropshipPackinglist.Quantity <= 17 then '1090x720x570'
WHEN DropshipPackinglist.Quantity >=1 and DropshipPackinglist.Quantity <= 6 then '1090x720x350'
ELSE 'Unkown'
end
as 'TOTAL VOLUME (MM3)'
FROM DropshipPackinglist INNER JOIN
HuaweiDescription ON DropshipPackinglist.ItemNumber = HuaweiDescription.ItemNumber
WHERE (DropshipPackinglist.BatchCode LIKE '%0005041007100AHWA11HG')
-------------------------------------------------------------------------------------------
Result:
CaseNumber ItemNumber Quantity TotalVolume
1 52411573 5 1090x720x350
1 52411576 20 1090x730x1000
2 52411576 36 1090x730x1460
-------------------------------------------------------------------------------------------
Now is, i want to group casenumber and result with only one totalvolume.
And the result will be this one.
CaseNumber ItemNumber Quantity TotalVolume
1 52411573 5 1090x730x1230 -- sum(casenumber 1)=25
1 52411576 20 1090x730x1230 --
2 52411576 36 1090x730x1460
How to solve this one..thanks in regards.
;with SuperSelect as
(
SELECT dpl.CaseNumber as 'CASE NO.'
,dpl.ItemNumber as 'BOM NO.'
,dpl.Quantity as 'QTY'
,CASE WHEN dpl.Quantity >= 31 and dpl.Quantity <= 36 then '1090x730x1460'
WHEN dpl.Quantity >= 25 and dpl.Quantity <= 30 then '1090x730x1230'
WHEN dpl.Quantity >= 19 and dpl.Quantity <= 24 then '1090x730x1000'
WHEN dpl.Quantity >= 13 and dpl.Quantity <= 18 then '1090x720x790'
WHEN dpl.Quantity >= 7 and dpl.Quantity <= 17 then '1090x720x570'
WHEN dpl.Quantity >= 1 and dpl.Quantity <= 6 then '1090x720x350'
ELSE 'Unkown'
end as 'TOTAL VOLUME (MM3)'
FROM DropshipPackinglist dpl
INNER JOIN HuaweiDescription hd ON dpl.ItemNumber = hd.ItemNumber
WHERE (dpl.BatchCode LIKE '%0005041007100AHWA11HG')
)
select *, sum([QTY]) over (partition by ss.[CASE NO.]) [TotalVolume]
from SuperSelect ss
If you need just one row per caseNumber then use
SELECT CaseNumber, Quantity, SUM(ItemNumber) TotalVolume
FROM (...YourOriginalQuery...)
GROUP BY CaseNumber, Quantity
If you need all rows but want also report Total per case number then use the following query:
SELECT CaseNumber, ItemNumber, Quantity,
SUM(ItemNumber) OVER(PARTITION BY CaseNumber) TotalVolume
FROM (SELECT DropshipPackinglist.CaseNumber, DropshipPackinglist.ItemNumber,
DropshipPackinglist.Quantity,
CASE
WHEN DropshipPackinglist.Quantity >= 31
AND DropshipPackinglist.Quantity <= 36 THEN
'1090x730x1460'
WHEN DropshipPackinglist.Quantity >= 25
AND DropshipPackinglist.Quantity <= 30 THEN
'1090x730x1230'
WHEN DropshipPackinglist.Quantity >= 19
AND DropshipPackinglist.Quantity <= 24 THEN
'1090x730x1000'
WHEN DropshipPackinglist.Quantity >= 13
AND DropshipPackinglist.Quantity <= 18 THEN
'1090x720x790'
WHEN DropshipPackinglist.Quantity >= 7
AND DropshipPackinglist.Quantity <= 17 THEN
'1090x720x570'
WHEN DropshipPackinglist.Quantity >= 1
AND DropshipPackinglist.Quantity <= 6 THEN
'1090x720x350'
ELSE
'Unkown'
END AS 'TOTAL VOLUME (MM3)'
FROM DropshipPackinglist
INNER JOIN HuaweiDescription
ON DropshipPackinglist.ItemNumber = HuaweiDescription.ItemNumber
WHERE (DropshipPackinglist.BatchCode LIKE '%0005041007100AHWA11HG'))
Related
I was trying to set a range of numbers at text box (CHWV.text) which will able to update my database base on my if else condition.
I tried to key into the text box from 0 to 100. then use int.TryParse to convert the text box value into an integer.
However, CHWTemp always get 0 whatever numbers i try enter.
The codes run perfectly,but i cannot get the CHWTemp i wanted after entering into the text box.
I not sure Is there anything i missed out?
sqlite_cmd = sqlite_conn.CreateCommand();
int CHWTemp;
int.TryParse(CHWV.Text,out CHWTemp);
try
{
sqlite_conn.Open();
if (CHWTemp >= 0 && CHWTemp <= 10)
{
sqlite_cmd.CommandText = ("UPDATE Temperature SET Temp = 25 where id=12");
sqlite_cmd.ExecuteNonQuery();
}
else if (CHWTemp >= 11 && CHWTemp <= 20)
{
sqlite_cmd.CommandText = ("UPDATE Temperature SET Temp = 24 Where id=12");
sqlite_cmd.ExecuteNonQuery();
}
else if (CHWTemp >= 21 && CHWTemp <= 40)
{
sqlite_cmd.CommandText = ("UPDATE Temperature SET Temp = 23 where id=12");
sqlite_cmd.ExecuteNonQuery();
}
else if (CHWTemp >= 41 && CHWTemp <= 60)
{
sqlite_cmd.CommandText = ("UPDATE Temperature SET Temp = 22 where id=12");
sqlite_cmd.ExecuteNonQuery();
}
else if (CHWTemp >= 61 && CHWTemp <= 80)
{
sqlite_cmd.CommandText = ("UPDATE Temperature SET Temp = 21 where id=12");
sqlite_cmd.ExecuteNonQuery();
}
else if (CHWTemp >= 81 && CHWTemp <= 100)
{
sqlite_cmd.CommandText = ("UPDATE Temperature SET Temp = 20 where id=12");
sqlite_cmd.ExecuteNonQuery();
}
sqlite_conn.Close();
}
catch ()
{
}
Any help is much appreciated. Thanks.
Before using the value of CHWTemp please check the return value of int.TryParse(CHWV.Text,out CHWTemp); If you are getting false than the conversion is not happening from string to int.
bool ifSuccess = int.TryParse(CHWV.Text,out CHWTemp);
if the value of ifSuccess is true then conversion from string to int is done but if the value of CHWV.Text is not convertible to int you will get false in return and the value of CHWTemp will be 0.
Just check that your getting the correct string from the text box. That's it.
Actually your code seems good to me. To be safe, I created this fiddle, in which I removed all sql related stuff, and replaced them with Console.WriteLine's.
using System;
public class Program
{
public static void Main()
{
int CHWTemp;
String inputStr = "17";
int.TryParse(inputStr,out CHWTemp);
if (CHWTemp >= 0 && CHWTemp <= 10)
{
Console.WriteLine("UPDATE Temperature SET Temp = 25 where id=12");
}
else if (CHWTemp >= 11 && CHWTemp <= 20)
{
Console.WriteLine("UPDATE Temperature SET Temp = 24 Where id=12");
}
else if (CHWTemp >= 21 && CHWTemp <= 40)
{
Console.WriteLine("UPDATE Temperature SET Temp = 23 where id=12");
}
else if (CHWTemp >= 41 && CHWTemp <= 60)
{
Console.WriteLine("UPDATE Temperature SET Temp = 22 where id=12");
}
else if (CHWTemp >= 61 && CHWTemp <= 80)
{
Console.WriteLine("UPDATE Temperature SET Temp = 21 where id=12");
}
else if (CHWTemp >= 81 && CHWTemp <= 100)
{
Console.WriteLine("UPDATE Temperature SET Temp = 20 where id=12");
}
}
}
As you can see, it works just fine. So, it is easy to say, parsing part works as expected. Therefore I think the point of failure looks like how you get the string from your text field.
So, my suggestion for you is to make sure that CHWV.Text returns a string representation of the number you enter.
Cheers,
Console.WriteLine(" Even Table \n");
int MaxNumber = 100;
int EvenNumbers = 0;
int i;
for (i = 0; i <=MaxNumber; i+=2)
{
if (i % 2 == 0)
{
EvenNumbers = i;
}
Console.Write(EvenNumbers);
}
OUTPUT:
Even Table
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100
I am making a program that displays the even numbers between 2 and 100 inclusively. I am able to display the even numbers, although the formatting for the output is in a straight line due to the Console.Write, is there a string format that can I use to have the output display each even number, but cut to a new line every interval of 20? So it would look like:
1-20
20-40
40-60
ETC
Less lines with Linq! :p
foreach (var even in Enumerable.Range(2, 100).Where(i => i % 2 == 0))
Console.Write(even % 20 != 0 ? even.ToString() + " " : even.ToString() + "\n");
Use this:
for (i = 0; i <=MaxNumber; i+=2)
{
EvenNumbers = i;
Console.Write(EvenNumbers+" ");
if(i%20==0){
Console.WriteLine();
}
}
You do not need condition if (i % 2 == 0) because your step is 2.
In complement for Luis solution, you can do it easily with this code :
foreach (var item in Enumerable.Range(1, 100).Where(o => o % 2 == 0).GroupBy(o => (int)(o / 20.01)))
{
Console.WriteLine(string.Join(" ", item.ToArray()));
}
Loop on group by '20' filtered by modulo 2 enumeration of int and print it in one line with string.join
You need to cast the groupby if you want your first number are 20, 40, 60... else it starts with 22, 42, 62...
Hope this helps
Try below; It will consider 0 as well; Otherwise 0 will be isolated.
Console.WriteLine(" Even Table \n");
int MaxNumber = 100;
int EvenNumbers = 0;
int i;
for (i = 0; i <= MaxNumber; i += 2)
{
if (i % 2 == 0)
{
EvenNumbers = i;
}
Console.Write(" ");
Console.Write(EvenNumbers);
if (i % 20 == 0 && i>0)
{
Console.WriteLine();
}
}
Here is a different approach using Enumerable.Range and String.Join:
int MaxNumber = 100;
// create a list of all even numbers
List<int> even_list = Enumerable.Range(0, MaxNumber+1).Where(x => x % 2 == 0).ToList();
// for the amount of numbers to be displayed in a line
int numbers_in_single_line = 10
for (int i = 1; i <= even_list.Count; i += numbers_in_single_line)
{
Console.WriteLine(String.Join(" ", even_list.Skip(i).Take(numbers_in_single_line )));
}
Skip() and Take() allow you to select values from the list at certain positions
Is there a method or command to increment logarithmic?
So how I can increment Integer:
int i = 0
while (i < 100)
{
i++
}
result: 1, 2, 3 ... ,100
Up to now I'm doing this:
double i = 0;
while (i < 100)
{
if (i >= 10)
{
i += 10;
}
else if (i >= 1 & i < 10)
{
i += 1;
}
else if (i >= 0.1 & i < 1)
{
i += 0.1;
}
else if (i < 0.1)
{
i += 0.01;
}
}
result: 0.1, 0.2, 0.3 ... 1, 2, 3 .... 10, 20, 30 ... 100
With a bigger range from 0.001 - 1000 is that troublesome
The second question is:
If i = 0.05 and I increment i += 0.01 then is the result 0.060000000000000005. Why it increment 0.010000000000000005 and not 0.01?
you could shorten your code with two for next loops, leave al the if/elses and replace them with a Math.Pow. n defines the granularity (n^-2 = 0,01)
int n,m;
for( n=-2 ; n < 3; n++ )
{
for( m= 1 ; m < 10 ; m++ )
{
Console.WriteLine(m * Math.Pow(10,n));
}
}
result:
0,01 , 0,02 , 0,03 , 0,04 , 0,05 , 0,06 , 0,07 , 0,08 , 0,09 , 0,1 , 0,2 , 0,3 , 0,4 , 0,5 , 0,6 , 0,7 , 0,8 , 0,9 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 , 200 , 300 , 400 , 500 , 600 , 700 , 800 , 900
I tried to convert Int to Varchar but I'm unable to get output. Can anyone suggest any other way to do so?
I have below query and need to cast StoreNo (int) to a varchar:
ALTER PROCEDURE [dbo].[getrevenue]
#date1 DATE,
#date2 DATE,
#StoreNo NVARCHAR(max)
AS
BEGIN
DECLARE #sql_test NVARCHAR(max)
--SET #StoreNo='68,78,104'
SET #sql_test = 'SELECT t1.transtoreno AS StoreNO
,t3.NAME AS NAME
,t1.Dealdate AS DATE
,t1.UKEI AS UKEI
,t2.SubTotal AS SubTotal
,ISNULL(t2.SubTotalDiscount, 0) AS SubToatlDiscount
,ISNULL(t1.twoeyesSubtotalDiscount, 0) AS TwoeyeSubTotalDiscount
,t2.ValueInquiries AS TotalDiscount
,t2.NetSale AS Netsale
,t2.TotalSale AS ToatlSale
,t2.Cash AS Cash
,ISNULL(t2.GiftVochuer, 0) AS GiftVochuer
,ISNULL(t2.Card, 0) AS Card
,ISNULl(t2.Suica, 0) AS Suica
,t2.WONPOINT AS WAONPOINT
,t1.TaxExemption AS TAXExemption
,t2.TaxTotal AS TaxTotal
,t2.Returngoods AS Returngoods
,t2.Regiminus AS RegiMinus
,t2.PrintRecipt AS printrecipt
,ISNULL(t1.Visitorcount, 0) AS VisitorCount
FROM (
SELECT CAST(StoreNo AS NVARCHAR) AS transtoreno
,(DealDate) AS Dealdate
,SUM(SalePrice) AS UKEI
,SUM(TansuNebikiPrice) AS twoeyesdicount
,SUM(SubTotalNebiki2Price) AS twoeyesSubtotalDiscount
,SUM(TotalSalePrice - Si1Tax - RegiMinusNo) AS Netsale
,SUM(SpecialConsumptionTaxPrice) AS TaxExemption
,Sum(RegiMinusNo) AS Receiptissue
,SUM(VisitorCount) AS Visitorcount
FROM POS_TtlTran
GROUP BY StoreNo
,DealDate
) t1
LEFT OUTER JOIN (
SELECT DATE AS D
,cast(StoreNo AS NVARCHAR) AS s
,SUM(CASE
WHEN SerialNo LIKE 23
THEN DayTotalAmt
ELSE 0
END) AS Cash
,SUM(CASE
WHEN SerialNo LIKE 31
THEN DayTotalAmt
ELSE 0
END) AS Card
,SUM(CASE
WHEN SerialNo LIKE 30
THEN DayTotalAmt
ELSE 0
END) AS GiftVochuer
,SUM(CASE
WHEN SerialNo LIKE 138
THEN DayTotalAmt
ELSE 0
END) AS Returngoods
,SUM(CASE
WHEN SerialNo LIKE 160
THEN DayTotalAmt
ELSE 0
END) AS PrintRecipt
,SUM(CASE
WHEN SerialNo LIKE 304
THEN DayTotalAmt
ELSE 0
END) AS Suica
,SUM(CASE
WHEN SerialNo LIKE 26
THEN DayTotalAmt
ELSE 0
END) AS WONPOINT
,SUM(CASE
WHEN SerialNo LIKE 139
THEN DayTotalAmt
ELSE 0
END) AS Regiminus
,SUM(CASE
WHEN SerialNo LIKE 4
THEN DayTotalAmt
ELSE 0
END) AS SubToTal
,SUM(CASE
WHEN SerialNo LIKE 7
THEN DayTotalAmt
ELSE 0
END) AS SubTotalDiscount
,SUM(CASE
WHEN SerialNo LIKE 8
THEN DayTotalAmt
ELSE 0
END) AS TwoeyesubTotalDiscount
,SUM(CASE
WHEN SerialNo LIKE 18
THEN DayTotalAmt
ELSE 0
END) AS ValueInquiries
,SUM(CASE
WHEN SerialNo LIKE 22
THEN DayTotalAmt
ELSE 0
END) AS TotalSale
,SUM(CASE
WHEN SerialNo LIKE 114
THEN DayTotalAmt
ELSE 0
END) AS TaxTotal
,SUM(CASE
WHEN SerialNo LIKE 2
THEN DayTotalAmt
ELSE 0
END) AS NetSale
FROM POS_FinTtl
GROUP BY StoreNo
,DATE
) t2 ON t1.transtoreno = t2.s
AND t1.Dealdate = t2.D
LEFT OUTER JOIN (
SELECT StoreNo AS No
,StoreName AS NAME
FROM Store
) t3 ON t2.s = t3.No
WHERE (
t1.transtoreno IN ('''
+ CAST(#StoreNo AS NVARCHAR(max)) + ''')
AND (t1.Dealdate between ''' + CAST(#date1 AS VARCHAR(30)) + '''
AND ''' + CAST(#date2 AS VARCHAR(30)) + '''))'
END
Hope this one will work
ALTER PROCEDURE [dbo].[getrevenue] #date1 DATE
,#date2 DATE
,#StoreNo NVARCHAR(max) `
AS
BEGIN
DECLARE #sql_test NVARCHAR(max)
--SET #StoreNo='68,78,104'
SET #sql_test ='SELECT t1.transtoreno AS StoreNO
,t3.NAME AS NAME
,t1.Dealdate AS DATE
,t1.UKEI AS UKEI
,t2.SubTotal AS SubTotal
,ISNULL(t2.SubTotalDiscount, 0) AS SubToatlDiscount
,ISNULL(t1.twoeyesSubtotalDiscount, 0) AS TwoeyeSubTotalDiscount
,t2.ValueInquiries AS TotalDiscount
,t2.NetSale AS Netsale
,t2.TotalSale AS ToatlSale
,t2.Cash AS Cash
,ISNULL(t2.GiftVochuer, 0) AS GiftVochuer
,ISNULL(t2.Card, 0) AS Card
,ISNULl(t2.Suica, 0) AS Suica
,t2.WONPOINT AS WAONPOINT
,t1.TaxExemption AS TAXExemption
,t2.TaxTotal AS TaxTotal
,t2.Returngoods AS Returngoods
,t2.Regiminus AS RegiMinus
,t2.PrintRecipt AS printrecipt
,ISNULL(t1.Visitorcount, 0) AS VisitorCount
FROM (
SELECT CAST(StoreNo AS NVARCHAR) AS transtoreno
,(DealDate) AS Dealdate
,SUM(SalePrice) AS UKEI
,SUM(TansuNebikiPrice) AS twoeyesdicount
,SUM(SubTotalNebiki2Price) AS twoeyesSubtotalDiscount
,SUM(TotalSalePrice - Si1Tax - RegiMinusNo) AS Netsale
,SUM(SpecialConsumptionTaxPrice) AS TaxExemption
,Sum(RegiMinusNo) AS Receiptissue
,SUM(VisitorCount) AS Visitorcount
FROM POS_TtlTran
GROUP BY StoreNo
,DealDate
) t1
LEFT OUTER JOIN (
SELECT DATE AS D
,cast(StoreNo AS NVARCHAR) AS s
,SUM(CASE
WHEN SerialNo LIKE 23
THEN DayTotalAmt
ELSE 0
END) AS Cash
,SUM(CASE
WHEN SerialNo LIKE 31
THEN DayTotalAmt
ELSE 0
END) AS Card
,SUM(CASE
WHEN SerialNo LIKE 30
THEN DayTotalAmt
ELSE 0
END) AS GiftVochuer
,SUM(CASE
WHEN SerialNo LIKE 138
THEN DayTotalAmt
ELSE 0
END) AS Returngoods
,SUM(CASE
WHEN SerialNo LIKE 160
THEN DayTotalAmt
ELSE 0
END) AS PrintRecipt
,SUM(CASE
WHEN SerialNo LIKE 304
THEN DayTotalAmt
ELSE 0
END) AS Suica
,SUM(CASE
WHEN SerialNo LIKE 26
THEN DayTotalAmt
ELSE 0
END) AS WONPOINT
,SUM(CASE
WHEN SerialNo LIKE 139
THEN DayTotalAmt
ELSE 0
END) AS Regiminus
,SUM(CASE
WHEN SerialNo LIKE 4
THEN DayTotalAmt
ELSE 0
END) AS SubToTal
,SUM(CASE
WHEN SerialNo LIKE 7
THEN DayTotalAmt
ELSE 0
END) AS SubTotalDiscount
,SUM(CASE
WHEN SerialNo LIKE 8
THEN DayTotalAmt
ELSE 0
END) AS TwoeyesubTotalDiscount
,SUM(CASE
WHEN SerialNo LIKE 18
THEN DayTotalAmt
ELSE 0
END) AS ValueInquiries
,SUM(CASE
WHEN SerialNo LIKE 22
THEN DayTotalAmt
ELSE 0
END) AS TotalSale
,SUM(CASE
WHEN SerialNo LIKE 114
THEN DayTotalAmt
ELSE 0
END) AS TaxTotal
,SUM(CASE
WHEN SerialNo LIKE 2
THEN DayTotalAmt
ELSE 0
END) AS NetSale
FROM POS_FinTtl
GROUP BY StoreNo
,DATE
) t2 ON t1.transtoreno = t2.s
AND t1.Dealdate = t2.D
LEFT OUTER JOIN (
SELECT StoreNo AS No
,StoreName AS NAME
FROM Store
) t3 ON t2.s = t3.No
WHERE (
t1.transtoreno IN ('''
+ CONVERT(varchar(MAX), #StoreNo) + ''')
AND (t1.Dealdate between ''' + CAST(#date1 AS VARCHAR(30)) + '''
AND ''' + CAST(#date2 AS VARCHAR(30)) + '''))'
END
where (t1.transtoreno IN ('''
+ CAST(#StoreNo AS nvarchar(max)) + ''')
Should be
where (t1.transtoreno IN ('''
+ replace(CAST(#StoreNo AS nvarchar(max)),',',''',''') + ''')
int i;
int[] mArray = new int[5];
for (i = 0; i < mArray.Length; i++)
{
Console.WriteLine("Please enter a number:");
mArray[i] = Convert.ToInt32(Console.ReadLine());
if (mArray[i] >= 50 && mArray[i] <= 10)
{
Console.WriteLine("Please enter numbers only between 10 and 50.");
mArray[i] = Convert.ToInt32(Console.ReadLine());
}
}
Can't seem to get if statement to work when it has two rules in it if (mArray[i] >= 50 && mArray[i] <= 10)
But it works fine with 1 rule if (mArray[i] >= 50)
You should use || instead of &&
mArray[i] >= 50 || mArray[i] <= 10
Look at your condition:
if (mArray[i] >= 50 && mArray[i] <= 10)
You're trying to find a number which is simultaneously at least 50 and at most 10.
What number did you have in mind that would be considered invalid?
I suspect you meant:
if (mArray[i] > 50 || mArray[i] < 10)
Note that I've changed >= and <= to > and < respectively to match your message - I assume you want 10 or 50 to be valid.
Also note that you're only testing for validity once - if the user persists in entering a second bad number, you'll accept that. I suspect you want something like:
Console.WriteLine("Please enter a number:");
int value = Convert.ToInt32(ConsoleReadLine());
while (value > 50 || value < 10)
{
Console.WriteLine("Please enter numbers only between 10 and 50.");
value = Convert.ToInt32(Console.ReadLine());
}
// Now we know it's valid, so it's reasonably to put it in the array
mArray[i] = value;
Which number is bigger than 50 AND in the same moment smaller then 10? I think you should replace your && (AND) with || (OR)
No number can be larger than 50 AND smaller than 10, your condition is wrong:
if (mArray[i] >= 50 && mArray[i] <= 10)
it should be
if (mArray[i] >= 50 || mArray[i] <= 10)
It depends on how you intend to make it work
/*Pass if the value is more or equal 50 OR lesst or equal 10*/
mArray[i] >= 50 || mArray[i] <= 10
or
/*Passs if the value is between 10 and 50, including edges*/
mArray[i] >= 10 && mArray[i] <= 50
Your statement is impossible. myArray[i] has to be both larger than 50 AND smaller than 10. Did you mean:
if (mArray[i] >= 50 || mArray[i] <= 10)
?
Try changing your logic to:
if (mArray[i] >= 50 || mArray[i] <= 10)