访问查询 - 计数(*)为sl_no order by不起作用? [英] Access Query - Count(*) as sl_no order by is not working?

查看:73
本文介绍了访问查询 - 计数(*)为sl_no order by不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问查询包含count(*)来选择像Row_Number(),但是order by不像预期的结果那样工作。



我的查询:

选择


partymst
中选择
count(*)
其中
pt.ID> = ID由pt.pty_name订购)为sl_no,
pt。*来自partymst为pt order by pt.pty_name



上面的声明给出了类似下面的输出。

 Sl-No Name 
2 Maheswaran& Co
3 Pollachi Thatha& co
1 Pollachi Kodi Thatha



那么,如何实现sl_no 1,2,3



感谢您正确的指示。

解决方案

  SELECT  * 
FROM

选择
SELECT count(*) FROM partymst WHERE pt。 ID> = ID) AS sl_no
,pt。*
来自 partymst as pt
as temptbl
订单 sl_no



快乐编码!

:)


//我测试了以下代码,它在sql server中正常工作

试试这个agin让我知道ow



 //输入最后一个pt.pty_name  pt。 sl_no 
选择
选择
count(*)
来自
TestTable
其中
pt.ID> = ID) as sl_no,
pt.Name 来自 TestTable as pt

order by pt.ID


I have a access query contains count(*) to select as like Row_Number(), but the order by is not working like the expected result.

My Query :

Select 
    (
        select 
            count(*) 
        from 
            partymst 
        where 
            pt.ID>=ID order by pt.pty_name) as sl_no,
            pt.* from partymst as pt order by pt.pty_name


The above statement is giving like the following Output.

Sl-No Name 
2     Maheswaran & Co
3     Pollachi Thatha & co
1     Pollachi Kodi Thatha


So, how to achieve the sl_no by 1,2,3

Thanks for the right directions.

解决方案

SELECT *
FROM
(
         select
	(SELECT count(*) FROM partymst WHERE pt.ID >= ID) AS sl_no
	,pt.* 
	from partymst as pt
) as temptbl 
order by sl_no


Happy Coding!
:)


//i have tested the below code its working correctly in sql server
try this one agin and let me know

//chnage the last pt.pty_name to pt.sl_no
Select 
    (  select 
            count(*) 
        from 
            TestTable 
        where 
            pt.ID>=ID) as sl_no,
            pt.Name from TestTable as pt
 
         order by pt.ID


这篇关于访问查询 - 计数(*)为sl_no order by不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆