我在mysql表的表中看起来像
create table Pickup
(
PickupID int not null,
ClientID int not null,
PickupDate date not null,
PickupProxy varchar (40) ,
PickupHispanic bit default 0,
EthnCode varchar(2),
CategCode varchar (2) not null,
AgencyID int(3) not null,
Primary Key (PickupID),
FOREIGN KEY (CategCode) REFERENCES Category(CategCode),
FOREIGN KEY (AgencyID) REFERENCES Agency(AgencyID),
FOREIGN KEY (ClientID) REFERENCES Clients (ClientID),
FOREIGN KEY (EthnCode) REFERENCES Ethnicity (EthnCode)
);
sample data from my txt file
1065535,7709,1/1/2006,,0,,SR,6
1065536,7198,1/1/2006,,0,,SR,7
1065537,11641,1/1/2006,,0,W,SR,24
1065538,9805,1/1/2006,,0,N,SR,17
1065539,7709,2/1/2006,,0,,SR,6
1065540,7198,2/1/2006,,0,,SR,7
1065541,11641,2/1/2006,,0,W,SR,24
Run Code Online (Sandbox Code Playgroud)
当我试图通过使用提交它
LOAD DATA INFILE 'Pickup_withoutproxy2.txt' …Run Code Online (Sandbox Code Playgroud) 我有一个场景,我有一个对象列表,在对象中有一个日期时间字段.我试图找出是否有办法使用LINQ按顺序日期时间对列表进行分组,并返回列表的子集,其中顺序日期时间为范围.
public virtual IList<LineItem> LineItems { get; set; }
...
public class LineItem
{
public virtual string Status { get; set; }
public virtual DateTime TransDate { get; set; }
...
}
Run Code Online (Sandbox Code Playgroud)
所以如果我LineItem和Status = P所有人一起拥有6 秒
TransDate = { 8/1/2011 , 8/2/2011 , 8/3/2011 , 8/5/2011 , 8/6/2011 , 8/9/2011 }
Run Code Online (Sandbox Code Playgroud)
分别,我想返回以下列表:
{ (P, 8/1/2011-8/3/2011) , (P,8/5/2011-8/6/2011) , (P,8/9/2011) }
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?我可以手动迭代列表并检查TransDate以查看它是否是顺序的,我只是在寻找一种更优雅(最好是LINQ)的方式.谢谢!
我有以下代码,用于计算事件列中出现的内容的次数.
SELECT event, count(event) as event_count
FROM event_information
group by event
event event_count
a 34
b 256
c 45
d 117
e 3
Run Code Online (Sandbox Code Playgroud)
我希望能够像这样计算每一行的百分比.
event event_count event_percent
a 34 7.47
b 256 56.26
c 45 9.89
d 117 25.71
e 3 0.66
Run Code Online (Sandbox Code Playgroud) 我有2张桌子
部门
ID Dept
---------
1 HR
2 Accts
3 IT
Run Code Online (Sandbox Code Playgroud)
雇员
ID Name Depts
-------------------
1 Kevin 2,1
2 Michelle 1
3 Troy 1,3
4 Rheesa 2,3,1
Run Code Online (Sandbox Code Playgroud)
我正在寻找像SQL查询一样的输出.
员工部门
ID Name Depts
-------------------------
1 Kevin Accts,HR
2 Michelle HR
3 Troy HR,IT
4 Rheesa Accts,IT,HR
Run Code Online (Sandbox Code Playgroud)
我尝试了以下与depts连接,但只为每个dept生成一行.如何使用查询获得上述结果?
select
name, depts, dept
from
employee
CROSS APPLY
dbo.split_list(employee.depts ,',') split
inner join
dbo.department on depts= split.value
order by
name
Run Code Online (Sandbox Code Playgroud)