[Solved] GROUP BY in datatable select using c#

Try this using LINQ in C# var result = from tab in dt.AsEnumerable() group tab by tab[“ApplicationNmae”] into groupDt select new { ApplicationNmae = groupDt.Key, Sum = groupDt.Sum((r) => decimal.Parse(r[“Count”].ToString())) }; DataTable dt1 = new DataTable(); dt1 = dt.Clone(); foreach (var item in result) { DataRow newRow = dt1.NewRow(); newRow[“ApplicationNmae”] = item.ApplicationNmae; newRow[“Count”] = item.Sum; … Read more

[Solved] how to get sum(col2) as somename,(col2*col3)/Sum(col2) as somename1 for the some date

You can achieve what you’re after like below: CREATE TABLE SampleTable ([col1] varchar(1), [col2] int, [col3] int, [date] varchar(16)) ; INSERT INTO SampleTable ([col1], [col2], [col3], [date]) VALUES (‘a’, 11, 0, ‘3/6/2015:0:00:00’), (‘b’, 5, 4, ‘3/6/2015:0:00:00’), (‘c’, 5, 5, ‘3/6/2015:0:00:00’), (‘d’, 3, 0, ‘3/6/2015:0:00:00’), (‘e’, 21, 21, ‘3/6/2015:0:00:00’) ; SELECT t2.SumCol2, sum(t1.col2 * t1.col3) / … Read more

[Solved] sql to linq conversion for this table [closed]

You can do something like this:- var output= countries.GroupBy(c => new { c.State, c.City }) .Select(a => new { City = a.Key.City, State = a.Key.State, Zip = a.Max(z => z.Zip) }).OrderBy(m => m.City); 1 solved sql to linq conversion for this table [closed]

[Solved] difficulty giving aliases inside case statement

Use: Count(case when a.photoappimage is null then 1 end) as via_u, Count(case when a.photoappimage is null then 1 end)/100. as via_u_pct, Count(case when a.photoappimage=1 then 1 end ) as via_p, Count(case when a.photoAppImage is null or a.photoAppImage=1 then 1 end) as via_u_or_p Update: combining all (and use a subquery to simplify pct calculation): select storeId, … Read more

[Solved] Update table, but make a new updated table? [closed]

your code mysql_query(“UPDATE prestataire SET (login=’$a’, passe=”$b” , email=”$c”,nom=’$d’, prenom=’$e’, adresse=”$f”, ville=”$g”, tel=”$h” )WHERE login = ‘$a’ )”); try like this $sql = “UPDATE prestataire SET (login=’$a’, passe=”$b” , email=”$c”,nom=’$d’, prenom=’$e’, adresse=”$f”, ville=”$g”, tel=”$h” )”; $request = mysql_query($sql); better way $sql = “UPDATE prestataire SET passe=”$b” , email=”$c”,nom=’$d’, prenom=’$e’, adresse=”$f”, ville=”$g”, tel=”$h” WHERE login=’$a'”; You … Read more

[Solved] Please help querying for room’s availability [closed]

check this : http://sqlfiddle.com/#!2/d07965/20 Use this query. Only thing you are missing is equality condition. : select * from rooms A left join reservations B on A.id = B.room_id and B.reservation_date=”2014-01-11″ and B.start_period_id <= 11 and B.end_period_id >= 11 where B.room_id is null; Regards, Mansi solved Please help querying for room’s availability [closed]

[Solved] Could someone explain this php mysql script? [closed]

This question does not really belong here, but I’ll answer it for the sake of closing the question without bothering moderators. // mysql query is executed $images = mysql_query(“Select URL from images where Category = ‘Management’ “); // empty array initialized $imagerow = Array(); // while there are results of the executed mysql query while … Read more

[Solved] Converting a massive JSON file to CSV

A 48mb json file is pretty small. You should be able to load the data into memory using something like this import json with open(‘data.json’) as data_file: data = json.load(data_file) Dependending on how you wrote to the json file, data may be a list, which contains many dictionaries. Try running: type(data) If the type is … Read more

[Solved] How do I size and sapce

For problems like these, try to associate the output with its indices (or in this case, current_row). Also, it seems like it’s better to start from 0 for this one. 0: 1 1: 2 * 3 2: 4 * * * 5 3: 6 * * * * * 7 4: 8 * * * … Read more

[Solved] (select [amount] from [payment] where ([payment_account] = ‘Confirmation Deposit’) and ([action] = ‘Received’) and ([amount] = ’95’))

(select [amount] from [payment] where ([payment_account] = ‘Confirmation Deposit’) and ([action] = ‘Received’) and ([amount] = ’95’)) solved (select [amount] from [payment] where ([payment_account] = ‘Confirmation Deposit’) and ([action] = ‘Received’) and ([amount] = ’95’))