sql查询相关问题求指导

现有张员工表 sal字段表示员工工资 现在要查询这张表中工资最高的人是谁应该如何查询 我使用的是子查询 如下。哦 对了 表名叫t_employee。select * from t_employee where sal =(select Max(sal)from t_employee);请问除了子查询 还有什么方法可以查询出来工资最高的人的是谁
图片说明

sql
0

2个回答

连接查询,但没必要,能用简单的就用简答的。
 select t_employee.* from t_employee,(select Max(sal)from t_employee) a
 where a.sal=t_employee.sal
0

已经是最简单的实现方法了吧? 或者用过程来实现。。。

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
一个SQL查询列的问题,求指导
我有类似于这样的一张表:rnrnname card data l1 s1 l2 s2 l3 s3 l4 s4 l5 s5 l6 s6 l7 s7 l8 s8 l9 s9 l10 s10rn张三 11245 2011-7-15 基本工资 1500 饭贴 200 车贴 300 奖金 500rn李四 55264 2011-7-15 基本工资 1700 饭贴 200 车贴 300 奖金 470 优秀员工奖 200 rnrn我在查询某个人具体工资详情的时候,怎么查那么有数据的列啊,那些没有数据的列我就不显示rn比如我 select .... from salary where ....rn后显示的是 :rnrnname card data l1 s1 l2 s2 l3 s3 l4 s4 rn张三 11245 2011-7-15 基本工资 1500 饭贴 200 车贴 300 奖金 500rnrn或者是rnrnname card data l1 s1 l2 s2 l3 s3 l4 s4 l5 s5 rn李四 55264 2011-7-15 基本工资 1700 饭贴 200 车贴 300 奖金 470 优秀员工奖 200 rnrn这里的要怎么判断啊,能实现么,求高手指导rnrn
SQL查询的逻辑问题,求指导
[img=https://img-bbs.csdn.net/upload/201407/24/1406164888_193827.jpg][/img]rn如图,SQL语句怎把红色框框内的两行数据变为一行,也就是都多个类型(20,40,40HQ,45)的数据变为一行显示
求大神指导一个sql查询问题
有个表查出来的数据是如下显示的rn名称 位置rn1 arn1 brn1 crn2 drn2 ern怎么直接用sql语句让其显示出 固定四行,没有的用nullrn名称 位置1 位置2 位置 3rn1 a b crn2 d e null
SQL问题求指导
[img=https://img-bbs.csdn.net/upload/201404/03/1396491901_95533.jpg][/img]rn我想实现如图的功能,每次插入数据都能计算并存放到相对的位置,该怎么写。听朋友说可以用触发器,但我对SQL不熟练,只会一些简单的查询,求高手帮忙实现,谢谢!!![img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]
sql查询的相关问题
表结构rn id name nasidrn 1 nas1 1,2,3rn 2 nas2 2,3,4rn 3 nas3 2,3,5rnrnrn我现在有个两个nasid:1,2rn我想查询上面三条数据中nasid包含1,2(至少包含一个数字)的所有数据rnrn这个sql该怎么写呢,请各位高手给点思路,尝试过like,但是效率太低
hql 查询问题 求指导!!!!
消息表message: id, title, fb_user_id(发布消息者的id)n用户表user: id, namen中间表message_user: id, message_id, user_id(接受消息者的id)n已有用户id=001;n查询此用户发布的消息(message.fb_user_id=001)以及接受的消息(message_user.user_id=001),用一条hql语句查询n求指导
求财付通的相关指导
学校最近要做个网上买商品的网站,要求实现财付通支付的功能,在调用财付通的接口后,能成功支付。rn但在演示的那天,老师在支付成功后,把我的tomcat给关掉呢,因为在支付后,财付通会返回参数给我,然后我根据参数来讲客户数据插入到数据库,但由于他关掉了tomcat,我收不到财付通发过来的数据,从而无法保存到数据库,导致最后老师买了很多东西(东西就几毛钱一个),确在我的网站一个也查不到..
SQL跳字查询,求大神指导
现在想实现一共功能跳字查询,rn比如我有记录rncode name rn 01 张三李四rn 02 张三李四王五rn 03 张李四王五rn 04 张三王五rn 05 李四王五赵六rnrnrnrn我sql查询的时候输入“张李” 可以查询出如下三条记录rncode name rn 01 张三李四rn 02 张三李四王五rn 03 张李四王五rnrnrn求存储过程或者函数rnrnrn
求指导SQL语句问题
[code=sql]rnselect ID,name,sex, from tablearnWHERE name in(SELECT name FROM tableb where ClientNo ='8800034739')rn[/code]rn(后边这个Name查出来是这样:张三,李四,王五)rn为啥这样查不出来数据?
SQL问题,求大牛指导~~!!
在一个表中查询一个字段的值,有多个'范围约束条件',在这些范围约束条件中有一个主要的'范围约束条件'rn查询结果要求:要展示主约束条件不同时查询的字段值。rn 例子:rn 表格: arn 查询字段:AVG_PRCrn 查询条件:rn 主:STAT_CODE in(01,02,03,0201,0202,0203)rn 次主:ORG_NO in(61101,21101,42101,31101,13101)rn 辅:AMT_YM 在'201401'到'201410'之间rn 结果要求:展示不同条件下AVG_PRC的值rn 比如:rn stat_code=01,org_no=61101 时AVG_PRC在(AMT_YM 在'201401'到'201410'之间)的值 stat_code=02,org_no=61101 时AVG_PRC在(AMT_YM 在'201401'到'201410'之间)的rnrn值rn .rn .rn .rn stat_code=01,org_no=21101 时AVG_PRC在(AMT_YM 在'201401'到'201410'之间)的值 stat_code=02,org_no=21101 时AVG_PRC在(AMT_YM 在'201401'到'201410'之间)的rnrn值rn .rn .rn .rn 等等rn rn (stat_code不同时AVG_PRC代表的意思也不同)rn rn 直观的,表连接尽量少的,查询速度尽量快的
SQL 诡异的问题,求指导
写了一个存储过程,里面有对视图的更新操作。rnrn为啥在 exec 存储过程NAME 不报错rnrn但在NET程序中 调用 会报 ‘因为下列 SET 选项的设置不正确:'ARITHABORT'。请确保 SET 选项可正确用于计算列和/或查询通知和/或 xml 数据类型方法的索引视图和/或索引’rnrnrn另外我怎么查看 ARITHABORT 为ON还是OFF 命令是什么???rnrn视图不能直接更新么??为什么有时候有些字段更新不过来。。。rnrn问题有点多,谢谢各位英雄好汗!
求指导,sql优化的问题
各位大大们,下午好,小弟最近遇到一个sql的问题,sql如下rnSELECTrn ti.id,rn ti. NAME,rn ti.school,rn ti.photo,rn ti.department,rn ti.sex,rn ti.loveliness,rn ti.comment_count,rn tl.teacher_id AS teacherId,rnrnIF (rn avg(tl.level7) IS NULL,rn 0,rn avg(tl.level7)rn) AS level7,rn (rn avg(tl. LEVEL) + avg(tl.level6)rn) / 2 AS total,rn count(tl.id) AS realTotalCommentrnFROMrn teacher_info AS tirnLEFT JOIN teacher_level AS tl ON ti.id = tl.teacher_idrnINNER JOIN teacher_comment AS tc ON tl.comment_id = tc.idrnWHERErn ti.school = 26rnAND ti.is_shield = 1rnGROUP BYrn ti.idrnORDER BYrn realTotalComment DESCrnLIMIT 50;rn请问,如上sql是否需要优化,如果可优化怎么写效果比较好,烦请诸位指点一二,现在这里拜谢了
SQL问题求大神指导
SID PARENT_ID Codern100 MATrn1000 100 TJrn1010 100 AZrn101010 1010 001rn101090 101010 99rnrnrn如上,想将上面的数据转换成下面的结构(注:UI层上面的数据是树状结构,主键为SID,父节点为PARENT_ID,要求实现如下的样式,取出数据,且可以通过编号来追溯他的上级、上上级...)rnrnrnSID PARENT_ID Code Codesrn100 MAT MATrn1000 100 TJ MAT.TJrn1010 100 AZ MAT.AZrn101010 1010 001 MAT.AZ.001rn101090 101010 99 MAT.AZ.001.99
求sql,查询问题
select * from p_claim_head where claim_type != '4' 。如果claim_type=1的话,加个条件 host_send_no like '%DLK03%' rnselect * from p_claim_head where claim_type != '4' or claim_type=1 and host_send_no like '%DLK03%' 这种写法不对
求SQL查询问题
我在 select UserName as FName from t_User 中查出5条记录,我如何得到形如rn FID , FName rn 1 AAArn 2 BBBrn 3 CCCrn 4 DDDrn 5 666rnrn其中 FID 是记录的行号,非数据库字段
一个sql查询相关的问题
有一个表groups,下面有很多个字段rnidrnuserrncostrntypernaddtimernuptimernnotern.....rnrntype里面有5个类型,分别是001-005,rn现在要的结果就是查询最近6个月,001-005的总数,rn比如查询一月份,1号到31号,TYPE为001-005的数据rnselect count(*) from groups where type='001' and addtime<='20130101' and addtime >= '20130130'rnselect count(*) from groups where type='002' and addtime<='20130201' and addtime >= '20130230'rnselect count(*) from groups where type='003' and addtime<='20130301' and addtime >= '20130330'rnselect count(*) from groups where type='004' and addtime<='20130401' and addtime >= '20130430'rnselect count(*) from groups where type='005' and addtime<='20130501' and addtime >= '20130530'rn查询6个月的话就需要查询30次。rn如果有很多人登录这个系统,查询这样的SQL很耗费时间,我试过如果同时三个人都打开这个页面,大概反应时间要3秒以上rn我的思路就是有没有办法把这些查询结果写到一个表里面,这样查询的时候我直接查询的表的数据 ,然后这些SQL的数据我可以设置一个时间rn自动查询结果然后更新到一个表里面。这样我直接从表里面查询数据比用 count查询来得快,但是这个应该怎么实现呢,我现在用的就是最笨的rn办法,一个一个来查询,好卡啊。
推送相关问题,求大牛指导
我们的app是电商类的,现在接的推送,并不能满足我们对特殊用户进行特殊处理这种精准推送的要求,希望大家能帮忙推荐下个性化推送做的比较好的推送,小弟不胜感激
ipmi相关的知识,求指导
我现在在学习BMR-A2F-ATCA ,各种IPMI、ATCA协议方面的知识,资料都是英文的不是很懂,有没有这方面比较熟悉的小伙伴,能跟我交流一下吗,qq:1204011321,谢谢
Clistctrl相关问题求达人指导!
我做了2个对话框,每个对话框里分别有一个列表控件,我想实现2个列表控件间Item的相互发送,2个列表控件初始化什么的全都一样的,就是做的2个ID不同的功能相同的对话框,求指导!
SQL 相关子查询与group by的问题,谢谢指导
student(sno,sname,sdept)nncourse(cno,cname,ccredit)nnsc(sno,cno,grade)nn1、查询每个系的最高成绩nn select x.sno,sdept,grade from student x,scn where x.sno = sc.snon and grade =(select max(grade) from sc,studentn where sc.sno=student.sno and sdept=x.sdept)n n select x.sno,sdept,grade from student x,scn where x.sno = sc.snon and grade in(select max(grade) from sc,studentn where sc.sno=student.sno and sdept=x.sdept group by sdept)nnn select sdept,max(grade) from sc,student where sc.sno=student.sno group by sdeptnn //上面这三种写法结果是一样的,所以我想问第二种的写法的group by sdept是不是多余的呢?nn //另外,如果输出要加学号,为什么直接这样是输出了所有,又错了呢?n select sdept,sc.sno,max(grade) from sc,student where sc.sno=student.sno group by sdept,sc.sno
求一sql语句,查询比例相关
问sql语句rnrn我想从某表里面每次随机查询指定个数的记录(select top(xxx)),并且希望查询到的结果某列的值有一定的比例.rn比如下面的demo,随机从#t表内查询10条记录,,每次大约男生占60%,不要求绝对是这个值,但总体是这个比例..rn这个肿么弄....在线等rnrnrn[code=sql]rncreate table #t( id int IDENTITY(1,1) NOT NULL,xm nvarchar(10),xb char(2));rngorndeclare @i intrnset @i=1;rnwhile(@i<=50)rnbeginrninsert into #t(xm,xb) values('张' + CONVERT(nvarchar(8),@i),'男');rnset @i=@i+1rnendrnrnset @i=1;rnwhile(@i<=50)rnbeginrninsert into #t(xm,xb) values('王' + CONVERT(nvarchar(8),@i),'女');rnset @i=@i+1rnendrngornselect * from #t;rn[/code]
sql实验指导及相关原理
sql实验步骤及相关原理,对一些初学者来说有很大帮助
SQL语句求指导
A表是这样的rnnameidrnArnBrnCrnDrnErnFrnrnB表是这样的rnnameidrnFrnDrnArnrn现在要的结果是rnnameid statusrn A Yrn B Nrn C Nrn D Yrn E Nrn F YrnrnA表中的nameid在表B中的话status为Y,相反为NrnA表的数据量小rnB表的数据量很大rn求一个效率高点的SQL语句rnrnrn求大神指导
SQL 文求指导
select startdttime ,enddttime, startdttime +'~'+enddttime as dttimernfrom mytablern[color=#FF0000]startdttime +'~'+enddttime as dttime[/color]rn这个这个拼接的时候回出问题.说是字符型和DT型转换的问题..rn请问这个怎么整啊?
求大神指导SQL
Public Function LoadEQPDailyReport(Optional ByVal AreaNo As String = defString, Optional ByVal EquipmentNo As String = defString, _rn Optional ByVal StartTime As Date = defDateTime, Optional ByVal EndTime As Date = defDateTime, Optional ByVal AdditionalXml As String = "") As Stringrn Dim cnnTemp As OleDb.OleDbConnectionrn Dim daTemp As OleDb.OleDbDataAdapterrn Dim dsTemp As DataSetrn Dim drTemp As OleDb.OleDbDataReaderrn Dim strSQL As Stringrn Dim StartEndTime As Doublern Dim Rows() As DataRowrn Tryrn '//Create connectionrn cnnTemp = objLic.CreateConnection(strConnectionString)rn strSQL = "Select * From tblEQPStateBasis Order By EquipmentState"rn cmmTemp = New OleDb.OleDbCommand(strSQL, cnnTemp)rn drTemp = cmmTemp.ExecuteReader()rn strSQL = " Select (Select ContainareaNo From tblSMDAreaRelation Where ObjectNo = Z.EquipmentNo And ObjectType = 2) AreaNo," & _rn " (Select EquipmentType From tblEQPEquipmentBasis Where EquipmentNo = Z.EquipmentNo) EquipmentType," & _rn " Z.EquipmentNo," & _rn " 0 Moves"rn StartEndTime = DateDiff(DateInterval.Second, StartTime, EndTime)rn Do While drTemp.Readrn If strDataBaseType = "oracle" Thenrn rn strSQL = strSQL & " ,Nvl(Round(( Select Sum(Least(A.EndTime,To_Date('" & Format(CDate(EndTime), "yyyy/MM/dd HH:mm:ss") & "','YYYY/MM/DD HH24:MI:SS')) -" & _rn " Greatest(A.StartTime,To_Date('" & Format(CDate(StartTime), "yyyy/MM/dd HH:mm:ss") & "','YYYY/MM/DD HH24:MI:SS')))*24*60*60" & _rn " From (Select EquipmentType, EquipmentNo, EquipmentState, StartTime, EndTime From tblEMSEquipmentStateLog" & _rn " UNION All" & _rn " Select EquipmentType, EquipmentNo, EquipmentState, StartTime, SysDate EndTime From tblEMSEquipmentState" & _rn " ) A" & _rn " Where A.StartTime <= to_date('" & Format(CDate(EndTime), "yyyy/MM/dd HH:mm:ss") & "','YYYY/MM/DD HH24:MI:SS')" & _rn " And A.EndTime > to_date('" & Format(CDate(StartTime), "yyyy/MM/dd HH:mm:ss") & "','YYYY/MM/DD HH24:MI:SS')" & _rn " And A.EquipmentState = " & drTemp("EquipmentState") & _rn " And A.EquipmentNo = Z.EquipmentNo" & _rn " Group By A.EquipmentNo, A.EquipmentState)/" & StartEndTime & "*100,2),0) """ & drTemp("StateName") & """"rn ElseIf DataBaseType = "mssql" Or DataBaseType = "msaccess" Thenrn strSQL = strSQL & " ,ISNull(Round((CAST((Select Sum(DateDiff(Second," & _rn " (Case" & _rn " When A.StartTime > '" & Format(CDate(StartTime), "yyyy/MM/dd HH:mm:ss") & "' Then A.StartTime" & _rn " Else '" & Format(CDate(StartTime), "yyyy/MM/dd HH:mm:ss") & "'" & _rn " End)," & _rn " (Case" & _rn " When A.EndTime < '" & Format(CDate(EndTime), "yyyy/MM/dd HH:mm:ss") & "' Then A.EndTime" & _rn " Else '" & Format(CDate(EndTime), "yyyy/MM/dd HH:mm:ss") & "'" & _rn " End)))" & _rn " From (Select EquipmentType, EquipmentNo, EquipmentState, StartTime, EndTime From tblEMSEquipmentStateLog" & _rn " UNION All" & _rn " Select EquipmentType, EquipmentNo, EquipmentState, StartTime, GetDate() EndTime From tblEMSEquipmentState" & _rn " ) A" & _rn " Where A.StartTime <= '" & Format(CDate(EndTime), "yyyy/MM/dd HH:mm:ss") & "'" & _rn " And A.EndTime > '" & Format(CDate(StartTime), "yyyy/MM/dd HH:mm:ss") & "'" & _rn " And A.EquipmentState = " & drTemp("EquipmentState") & _rn " And A.EquipmentNo = Z.EquipmentNo" & _rn " Group By A.EquipmentNo, A.EquipmentState) as float) /CAST(" & StartEndTime & " AS float))*100,2),0) " & drTemp("StateName")rn End Ifrn Looprn drTemp.Close()rn cmmTemp.Dispose()rn strSQL = strSQL & " From tblEQPEquipmentBasis Z" & _rn " Where Z.EquipmentNo Is Not Null"rn rn If AreaNo <> defString Thenrn strSQL = strSQL & " And (Select ContainareaNo From tblSMDAreaRelation Where ObjectNo = Z.EquipmentNo And ObjectType = 2) = '" & AreaNo & "'"rn End Ifrn rn If EquipmentNo <> defString Thenrn strSQL = strSQL & " And EquipmentNo In ('" & Replace(EquipmentNo, ",", "','") & "')"rn End Ifrn rn If AdditionalXml <> "" Thenrn '//additionalconditionrn strSQL = strSQL & SeparateAddXML_Condition(AdditionalXml)rn End Ifrn strSQL = strSQL & " Order By EquipmentNo"rn '//Select Datarn cmmTemp = New OleDb.OleDbCommand(strSQL, cnnTemp)rn daTemp = New OleDb.OleDbDataAdapter(cmmTemp)rn dsTemp = New DataSetrn daTemp.Fill(dsTemp, "EQPDailyReport")rn If strDataBaseType = "oracle" Thenrn strSQL = " Select EquipmentNo, Sum(B.GoodQty) Moves" & _rn " From tblWIPCont_Equipment A, tblWIPLotLog_Report B" & _rn " Where A.LogGroupSerial = B.LogGroupSerial" & _rn " And A.EndTime Is Not Null " & _rn " And A.EndTime >= To_Date('" & Format(CDate(StartTime), "yyyy/MM/dd HH:mm:ss") & "','YYYY/MM/DD HH24:MI:SS') " & _rn " And A.EndTime < To_Date('" & Format(CDate(EndTime), "yyyy/MM/dd HH:mm:ss") & "','YYYY/MM/DD HH24:MI:SS') " & _rn "Group By EquipmentNo"rn ElseIf DataBaseType = "mssql" Or DataBaseType = "msaccess" Thenrn strSQL = " Select EquipmentNo, Sum(B.GoodQty) Moves" & _rn " From tblWIPCont_Equipment A, tblWIPLotLog_Report B" & _rn " Where A.LogGroupSerial = B.LogGroupSerial" & _rn " And A.EndTime Is Not Null " & _rn " And A.EndTime >= '" & Format(CDate(StartTime), "yyyy/MM/dd HH:mm:ss") & "'" & _rn " And A.EndTime < '" & Format(CDate(EndTime), "yyyy/MM/dd HH:mm:ss") & "'" & _rn "Group By EquipmentNo"rn End Ifrn cmmTemp = New OleDb.OleDbCommand(strSQL, cnnTemp)rn drTemp = cmmTemp.ExecuteReader()rn Do While drTemp.Readrn Rows = dsTemp.Tables("EQPDailyReport").Select("EquipmentNo = '" & drTemp("EquipmentNo") & "'")rn If Rows.Length <> 0 Thenrn Rows(0).Item("Moves") = drTemp("Moves")rn End Ifrn Looprn drTemp.Close()rn cmmTemp.Dispose()rn '//Combine Return Valuern LoadEQPDailyReport = CombineXMLReturnValue("loadeqpdailyreport", "EQPDailyReport", _rn "DataSet", FormatXMLSchema(dsTemp.GetXmlSchema), dsTemp.GetXml, "")rn Catch e1 As Exceptionrn LoadEQPDailyReport = "fail"rn rn Throw 'New Exception("clsReport.LoadEQPDailyReport: " & e1.Message)rn Finallyrn Call objLic.CloseConnection(cnnTemp)rn If Not daTemp Is Nothing Thenrn daTemp.Dispose()rn End Ifrn If Not dsTemp Is Nothing Thenrn dsTemp.Dispose()rn End Ifrn End Tryrn End Functionrnrnrn谁能帮我从里面抠出最终的SQL来,用的是ORACLE数据库
SQL题求指导
[code=sql]rnCREATE TABLE #CLOCKrn(rn SYSUSER VARCHAR(20),rn CLOCKTYPE VARCHAR(10),rn CLOCKTIME DATETIME,rn CLOCKDT DATErn)rnINSERT INTO #CLOCKrnSELECT '1001','IN','2014-10-09 9:00:00','2014-10-09'rnUNION ALLrnSELECT '1001','OUT','2014-10-09 10:00:00','2014-10-09'rnUNION ALLrnSELECT '1001','IN','2014-10-09 11:05:00','2014-10-09'rnUNION ALLrnSELECT '1001','IN','2014-10-09 11:10:00','2014-10-09'rnUNION ALLrnSELECT '1001','OUT','2014-10-09 12:00:00','2014-10-09'rnUNION ALLrnSELECT '1001','OUT','2014-10-09 13:00:00','2014-10-09'rnUNION ALLrnSELECT '1001','IN','2014-10-09 18:00:00','2014-10-09'rnUNION ALLrnSELECT '1001','OUT','2014-10-09 20:00:00','2014-10-09'rnrnSELECT * FROM #CLOCKrn--DROP TABLE #CLOCKrn--以上为一个结果集rnrn--以下是需要实现的效果rnSELECT '1001' AS SYSUSER, '2014-10-09 09:00:00.000' AS CLOCKIN, '2014-10-09 10:00:00.000' AS CLOCKOUT,'2014-10-09' AS CLOCKDTrnUNION ALLrnSELECT '1001' AS SYSUSER, '2014-10-09 11:05:00.000' AS CLOCKIN, '2014-10-09 13:00:00.000' AS CLOCKOUT,'2014-10-09' AS CLOCKDTrnUNION ALLrnSELECT '1001' AS SYSUSER, '2014-10-09 18:00:00.000' AS CLOCKIN, '2014-10-09 20:00:00.000' AS CLOCKOUT,'2014-10-09' AS CLOCKDT[/code]rnrn请先执行SQL查看结果集的变化。rnrn简单描述就是IN和OUT配对,但是中间可能出现连续多次IN或者OUT,根据CLOCKTIME来取最小的IN和最大的OUT配对。
Oracle SQL 求指导
select rn distinct p.userdefined2 as fld_TMD_order_no,rn ps.wmps_traceID as fld_TMD_connote_no,rn sum(NVL(os.userdefined2,0)* os.wmos_qtypicked) as fld_TOL_price,rn --sum(NVL(os.userdefined2,0)* os.wmos_qtypicked) as fld_TOL_total_amount,rn -- replace(to_char(wmsys.wm_concat(rtrim(ws.userdefined5))),',',';') as fld_edi_description,rn rn ws.userdefined5 as fld_edi_description,rn TO_CHAR(SYSDATE,'yyyymmdd') as fld_TM_manifest_id,rn 1 as fld_TM_cartons ,rn nvl(ps.wmps_grossweight,0)as fld_TM_cbm ,rn nvl(ps.wmps_cubic,0)as fld_TM_weight ,rn 'AIR'as fld_TM_container_type,rn '' as fld_TM_container_no,rn 'AUD' as fld_TM_seal_no,rn ''as fld_TM_vessel_name,rn TO_CHAR(SYSDATE+1,'DD/MM/YYYY') as fld_TM_edt, rn 1 as fld_TMD_cartons,rn nvl(ps.wmps_cubic, 0) as fld_TMD_cbm,rn nvl(ps.wmps_grossweight, 0) as fld_TMD_weight,rn to_char(sysdate,'Month dd yyyy hh:miAM','NLS_DATE_LANGUAGE = American')||'_BWB_Manifest' as fld_TO_filename,rn TO_CHAR(SYSDATE+3,'dd/mm/yyyy') as fld_TO_import_date,rn o.wmor_soreference2 as fld_TO_order_no,rn 1 as fld_TO_carrier,rn o.wmor_consigneename as fld_TO_surname,rn NVL(o.wmor_c_address1, ' ') as fld_TO_address_1,rn NVL(o.wmor_c_address2, ' ') as fld_TO_address_2,rn o.wmor_c_country as fld_TO_country_code,rn o.wmor_c_city as fld_TO_suburb,rn NVL(o.wmor_c_province, ' ') as fld_TO_state,rn o.wmor_c_zip as fld_TO_postcode,rn NVL(o.wmor_c_tel1, ' ') as fld_TO_telephone,rn 'AeParcelPac' as fld_TO_delivery_instr,rn NVL(o.wmor_c_address3, ' ') as fld_TO_address_3,rn NVL(ps.wmps_grossweight, 0) as fld_TO_weight,rn 1 as fld_TOL_line_no,rn '' as fld_TOL_product_no,rn '' as fld_TOL_item_no, rn 1 as fld_TOL_quantity, rn TO_CHAR(SYSDATE+5,'DD/MM/YY') as fld_TOL_promised_date, rnrn ws.userdefined5 as fld_edi_description,rn 'Jeanswest' as mame,rn '11th Floor, Unit C, 2 Tins Centre'as addr1,rn 'Hung Cheung Road 3' as addr2,rn 'Tuen Mun' as city,rn 'Hong Kong' as state,rn 'NA' as postcode,rn 'HK'as countryrnrnfrom wm_out_packing_summary ps,wm_out_packing p,wm_out_order o,wm_out_order_sku os,cd_wh_sku wsrnwhere rn ps.wmps_traceid=p.wmop_traceidrnand p.wmop_orderno=o.wmor_order_nornand p.wmop_sku_code=os.wmos_sku_codernand os.wmos_order_no=o.wmor_order_nornand ws.cdsk_sku_code=os.wmos_sku_coderngroup by ps.wmps_traceID,o.wmor_soreference2,o.wmor_consigneename,o.wmor_c_country,o.wmor_c_city,o.wmor_c_zip,ws.userdefined5,ps.wmps_grossweight,rnps.wmps_cubic,ps.wmps_cubic,ps.wmps_grossweight,o.wmor_c_address1,o.wmor_c_address2,o.wmor_c_province,o.wmor_c_tel1,o.wmor_c_address3,ps.wmps_grossweight, p.userdefined2;rnrn rn这个是我写的Sql语句,有点乱。。 查询出来后的结果是如图rnrn[img=https://img-bbs.csdn.net/upload/201407/23/1406083822_82073.png][/img]rnrn现在要以wmps_traceID 为主唯一查询,不要出现重复,然后要把价格累加。 还有一个 ws.userdefined5 字段里面有描述,要把 ws.userdefined5这个字段 不同的内容用 , 放一起显示出来,还不能重复。 rnrn重点的查询字段我都放在前面了。rn(业务就是 以箱子id为主,一个箱子里面 有很多个产品,然后每个产品的价格和数量不一样。要把一个箱子里面的所以的产品价格*数量 总价格显示出来,然后还要把每个产品的描述放一起用 , 分开。) rnrn这个sql语句该怎么写? 求指导。 求指导啊。
sql查询方法求指导
sql="select * from 表 where 字段1 OR 字段2 like '%"&keyword1&"%' OR '%"&keyword2&"%' order by id desc"rnrn通过查询关键字1和2搜索对应的字段,这种写法好像不能实现,求方法
SQL相关查询
总结相关知识,为经同意不得转载
查询SQL相关信息
1.查询SQL所有信息---------连接标识符,当前数据库,SSL,版本,端口 2.查询SQL版本号用select  version();查询端口号用show global variable like 'port';
SQL练习题——查询相关
1.查询选修了全部课程的学生姓名。SELECT SnameFROM StudentWHERE NOT EXISTS(SELECT *FROM CourseWHERE NOT EXISTS(SELECT *FROM SCWHERE Sno= Student.SnoAND Cno= Course.Cno);这道题我看了半天才给看懂了。说说思路:我们先关注最后这个 select * from sc wh...
SQL相关查询代码
共享好东西,也是找到别人写的,大家需要的一起学习使用哈
求一个sql查询的问题
如:rnselect * from createTable where xh>='445-2' and xh<'445-20'rnrn这是sqlserver2000下测试的,其中字段xh是varchar的,实际上数据库里xh字段的内容是这样的:rn445-1rn445-2rn445-3rn445-3rn。。。。。。。rnrn445-20rnrn但是,我通过这个语句查询的时候,只查到445-2这一条记录,我实际上是想查询这个范围里的所有数据,请求帮助
sql 查询问题 .求解决!!!
filesid filesname filesversion path filesUpLoadDatern 6 新建文本文档.txt 1.0.0.0 //update//新建文本文档.txt 2012-11-15 16:24:30.820rn 7 新建文本文档.txt 1.0.0.1 //update//新建文本文档.txt 2012-11-15 16:31:16.377rn 8 李剑锋.txt 1.0.0.0 //update//李剑锋.txt 2012-11-15 16:42:55.757rn 9 李剑锋.txt 1.0.0.1 //update//李剑锋.txt 2012-11-15 16:42:58.480rn 10 李剑锋.txt 1.0.0.2 //update//李剑锋.txt 2012-11-15 17:48:55.663rn ....当然这里还有很多数据.rn [color=#FF0000]无论它有多少,我现在以文件名称 列(filesname 去掉相同的 ) 拿到 rn 最新版本(filesversion )为最高的[/color] rn以上数据 查出结果为:rn[color=#339966] 7 新建文本文档.txt 1.0.0.1 //update//新建文本文档.txt 2012-11-15 16:31:16.377rn 10 李剑锋.txt 1.0.0.2 //update//李剑锋.txt 2012-11-15 17:48:55.663[/color] rn 请问sql 语句该怎么写 .
sql查询问题,求高手
种类 厂家 价格 规格型号rn铅笔 A 10 2Brn钢笔 B 20 HBrn圆珠笔 C 15 SBrnrn查询结果rn铅笔厂家 铅笔价格 铅笔规格型号 钢笔厂家 钢笔价格 钢笔规格型号 圆珠笔厂家 圆珠笔价格 圆珠笔规格型号rnA 10 2B B 20 HB C 15 SBrnrnrnrnrnrn
SQL查询问题,求解答
rndeclare @suma int,@sumb intrnset @suma=(select sum(t2.Finteger)FROM t_BOS200000001Entry2 t2 ) rnset @sumb=(select sum(t3.Finteger) FROM t_BOS200000002Entry2 t3 )rnselect t1.FText10 as'仓库',t2.FText2 as'物料名称',t2.FText as'收料客户',(@suma-@sumb) as'剩余数量',t2.FText3 as '单位' FROM t_BOS200000001Entry2 t2,t_BOS200000002Entry2 t3,t_BOS200000002 t4,t_BOS200000001 t1 WHERE t2.FText2=t3.FText3 AND t1.FText10=t4.FText AND t2.FText=t3.FText6 GROUP BY t1.FText10,t2.FText,t2.FText2,t2.FText3rn查询数据怎么根据“仓库”“物料名称”和“收料客户”来确定“剩余数量”里的值,不同的“仓库”“物料名称”和“收料客户”查询出来显示不同的值。上边是我现在的代码,但是查询的时候显示的值没有根据“仓库”“物料名称”和“收料客户”的值来确定。应该怎么改啊
SQL查询问题 求解决
有表A:rnm_id timern-------------------------------rn0 2011-07-01 00:00:00.000rn0 2011-07-01 01:00:00.000rn0 2011-07-01 02:00:00.000rn0 2011-07-01 03:00:00.000rn1 2011-07-01 04:00:00.000rn1 2011-07-01 05:00:00.000rn1 2011-07-01 06:00:00.000rn1 2011-07-01 07:00:00.000rn1 2011-07-01 08:00:00.000rnrn表B:rnid timern------------------------------------rn1 2011-07-01 00:00:00.000rn2 2011-07-01 01:00:00.000rn3 2011-07-01 02:00:00.000rn4 2011-07-01 03:00:00.000rn5 2011-07-01 04:00:00.000rn6 2011-07-01 05:00:00.000rn7 2011-07-01 06:00:00.000rn8 2011-07-01 07:00:00.000rn9 2011-07-01 08:00:00.000rn10 2011-07-01 09:00:00.000rn11 2011-07-01 10:00:00.000rn12 2011-07-01 11:00:00.000rn13 2011-07-01 12:00:00.000rn14 2011-07-01 13:00:00.000rn15 2011-07-01 14:00:00.000rn16 2011-07-01 15:00:00.000rn17 2011-07-01 16:00:00.000rn18 2011-07-01 17:00:00.000rn19 2011-07-01 18:00:00.000rn20 2011-07-01 19:00:00.000rn21 2011-07-01 20:00:00.000rn22 2011-07-01 21:00:00.000rn23 2011-07-01 22:00:00.000rn24 2011-07-01 23:00:00.000rnrn现在我要查询A表中有哪些M_ID的时间相对B表中time少了哪些时间? 要怎么查询?M_ID和ID没有关系
求一个SQL查询问题
表TB:rn装载号 物料 数量 静重 毛重rn1 X1 2 10 20rn1 X2 3 10 30rn2 X3 2 20 30rn2 X4 4 30 50rn2 X5 4 30 50rnrnrn要得到的结果是:rn装载号 物料 数量 重量rn2 X1 2 30rn2 X2 3 30rn3 X3 2 50rn3 X4 4 50rn3 X5 4 50rnrnrn对装载号相同的进行计数,对装载号相同的毛重减去静重,然后在进行数量汇总(比如装载号为1,重量就是(20-10)+(30-10))),本人不会写,请高手了
SQL查询求最小值问题?
表名为Event_Recordrngroup_no lift_no event_flag event_valuern1 1 36 20 rn1 2 36 30 rn1 3 36 26 rn2 4 36 50 rn2 5 36 60 rn2 6 36 56 rn1 1 37 120 rn1 2 37 130 rn1 3 37 126 rn2 4 37 150 rn2 5 37 160 rn2 6 37 156 rn1 1 37 80 rn1 2 37 90 rn1 3 37 86 rn2 4 37 70 rn2 5 37 80 rn2 6 37 76 rn1 1 36 60 rn1 2 36 50 rn1 3 36 42 rn2 4 36 36 rn2 5 36 38 rn2 6 36 40 rn做报表时要统计电梯开门(36)和并门(37)时的最小值,要得到如下数据:rnlift_no dooropen_min doorclose_minrn rn 1 1 20 80rn 1 2 30 90rn 1 3 26 86rn 2 4 36 70rn 2 5 38 80rn 2 6 40 76rnrnrn
关于查询问题,求SQL
大家好,rn假设我有A、B表,rnA表字段为教师编号、教师名称、所带班级rnB表字段为学号、姓名、教师编号、所在班级、成绩等级rn假如A表数据为:rn1 张三 01rn2 李四 02rn3 王五 03 rn4 赵六 04rnB表数据为:rn0101 学生1 1 01 Arn0102 学生2 1 01 Brn0103 学生3 1 01 Arn0201 学生4 2 02 Arn0202 学生5 2 02 Arn现在我想查询出教师名称,条件是所在班级只要成绩等级有不相同的结果查询出来。rn意思是比如张三所带的01班,如果成绩等级全部为A或B或C或D等,则不显示教师名称,如果成绩等级有不rnrn一样的,则显示出教师名称,谢谢大家了。rn比如上面提供的数据,最终查询出的结果应该是 张三rn因为张三所带01班的3个同学,成绩等级存在着A和B,而李四带的02班成绩等级都为A,则不显示查询结果rnrn。rn大家帮我看看这个SQL语句怎么写呢,谢谢大家了。
相关热词 c# 线程顺序 c#昨天当前时间 c# 多进程 锁 c#mysql图片存取 c# ocx 委托事件 c# 读取类的属性和值 c# out 使用限制 c#获取url的id c#怎么进行分页查询 c# update 集合