Litepal查询数据并按两个类别排序

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/fucong59/article/details/64134625

最近看郭霖老师的《第一行代码第二版》讲到Litepal,通过

DataSupport.order("x asc").find(Aps.class);
将aps表中的数据按x的大小升序排序,但是我做的东西要把数据库的所有数据读出来,并且按坐标的x,y排序。

在网上看了http://blog.csdn.net/lianghe_work/article/details/45039977的文章,说到sqlite可以用select * from aps order by x desc,id asc实现按x的降序和y的升序排序,于是在Litepal中写成

DataSupport.order("x asc,y asc").find(Aps.class);

中间用逗号隔开就可以实现按两个类别排序。



                                    
展开阅读全文

求助:两个表关联查询数据

09-11

如题,我有两个表A,BrnA是主表,B是从表B表有个字段表示 这票是否审核,rn比如说,我A表有一条数据,在B表有10条与A表对应的数据,如果B表这10条数据中有一条未审核的,那么就算这票未审核,求助高手这样的数据如何查呢?rn需要计算金额等等rn[code=sql]rnALTER proc [dbo].[BusinessQuery_SelectForZY]rn rn @InputMan varchar(50), rn @InputDepartment varchar(20),rn @EndInputDate datetime , rn @StartInputDate datetime, rnrn @Consignor varchar(100),rn @DeliveryListNum varchar(50), rn @ApproveNum varchar(20),rn @PermissionsCode VARCHAR(10) rnasrnbeginrndeclare @paySql varchar(5000)rnset @paySql ='select rnc.BusinessNum,rnc.InputMan [录入人],rnc.InputDate [录入时间],rnc.DeliveryListNum [提单号],rnc.ApproveNum [核销单号],rnc.CustomsNum [海关编号],rnCONVERT(VARCHAR(10),c.DeclareDate,120) [申报日期],rnb.Consignor [付费单位],rnc.Operate_Name [货主],rnc.ConveyanceName [船名],rnc.VoyageNum [航次],rn(sum(case f.CostType when ''0'' then f.ShouldMoney else 0 end )-sum(case f.CostType when ''1'' then f.ShouldMoney else 0 end)) [收入]rnfrom bus_BusinessDetail b,customs_CustomsDeclaration c,cost_FeeInfo frnwhere b.BusinessNum=c.BusinessNumrnand b.BusinessNum=f.BusinessNumrnand c.BusinessNum=f.BusinessNumrnand f.Flag_ManagerCheckCost = ''1'' --查询已经审核的rn'rnrnrnif @InputMan is not null rn beginrn set @PaySql = @PaySql+ ' and c.InputMan = '''+@InputMan+''''rn endrnrnif @InputDepartment is not null rn begin rn set @PaySql = @PaySql+ ' and c.InputDepartment = '''+@InputDepartment+''''rn endrnrnIF @StartInputDate IS NOT NULL AND @EndInputDate IS NOT NULLrn BEGINrn SET @PaySql = @PaySql + ' and c.InputDate BETWEEN ''' + CONVERT(VARCHAR(50),rn @StartInputDate,120) + ''' AND ''' + CONVERT(VARCHAR(50),@EndInputDate,120)rn + ''''rn endrnrnif @Consignor is not nullrn begin rn set @PaySql = @PaySql+' and b.Consignor='''+@Consignor+''''rn endrnrnif @DeliveryListNum is not nullrn begin rn set @PaySql=@PaySql+' and c.DeliveryListNum='''+@DeliveryListNum+''''rn endrnrnif @ApproveNum is not nullrn beginrn set @PaySql=@PaySql+' and c.ApproveNum='''+@ApproveNum+''''rn endrnrnif @PermissionsCode is not nullrn beginrn set @PaySql=@PaySql+' and b.PermissionsCode='''+@PermissionsCode+''''rn endrn set @PaySql=@PaySql+' group by c.BusinessNum,c.InputMan,c.InputDate,c.DeliveryListNum,c.ApproveNum,c.CustomsNum,rnc.DeclareDate,b.Consignor,c.Operate_Name,c.ConveyanceName,c.VoyageNum'rnprint (@PaySql)rnrnexec(@PaySql)rnrnendrn[/code]rn以上是我以前写的,现在客户要求值查询已审核的,如果这票当中的某一条数据未审核那么整票都查不到 论坛

没有更多推荐了,返回首页