I need some help writing this sql query.
I have three columns in my table
let call them
tOrderA,tOrderB,tContent
tOrderA,tOrderB are random integers from 1-10 000, tContent is a text field
so my table looks something like this
|tOrderA|tOrderB|tContent|
1 27 my
9 3 asfdf
152 16 sdfsd
18 22 dfdf
182 14 dfdsfs
tOrderA is my primary sort with levels (ie.1-100,101-200,201-300)
tOrderB is my secondary sort.
when the sort is applied the table should look like this.
|tOrderA|tOrderB|tContent|
9 3 asfdf
18 22 dfdf
1 27 my
182 14 dfdsfs
152 16 sdfsd
How would I write this query?
select tContent from tableA order by tOrderA ASC [range
1-100,101-200,201-300...] and tOrderB ASC
Thanks,
Aaronselect tOrderA, tOrderB, tContent
from tableA
order by (tOrderA + 1) / 100, tOrderB
"Aaron" wrote:
> I need some help writing this sql query.
> I have three columns in my table
> let call them
> tOrderA,tOrderB,tContent
> tOrderA,tOrderB are random integers from 1-10 000, tContent is a text fiel
d
> so my table looks something like this
> |tOrderA|tOrderB|tContent|
> 1 27 my
> 9 3 asfdf
> 152 16 sdfsd
> 18 22 dfdf
> 182 14 dfdsfs
>
> tOrderA is my primary sort with levels (ie.1-100,101-200,201-300)
> tOrderB is my secondary sort.
> when the sort is applied the table should look like this.
> |tOrderA|tOrderB|tContent|
> 9 3 asfdf
> 18 22 dfdf
> 1 27 my
> 182 14 dfdsfs
> 152 16 sdfsd
> How would I write this query?
> select tContent from tableA order by tOrderA ASC [range
> 1-100,101-200,201-300...] and tOrderB ASC
>
> Thanks,
> Aaron
>
>|||You mean:
select tOrderA, tOrderB, tContent
from tableA
order by (tOrderA - 1) / 100, tOrderB
^^^^^
With your code 99 and 100 will be in the [101 - 200] bracket.
Jacco Schalkwijk
SQL Server MVP
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:B77956D1-7821-4B24-B0A2-E898FA3B3F48@.microsoft.com...
> select tOrderA, tOrderB, tContent
> from tableA
> order by (tOrderA + 1) / 100, tOrderB
> "Aaron" wrote:
>|||Right ! Thanks! would that be the infamous "off by 2" error '
"Jacco Schalkwijk" wrote:
> You mean:
> select tOrderA, tOrderB, tContent
> from tableA
> order by (tOrderA - 1) / 100, tOrderB
> ^^^^^
> With your code 99 and 100 will be in the [101 - 200] bracket.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
> news:B77956D1-7821-4B24-B0A2-E898FA3B3F48@.microsoft.com...
>
>
Showing posts with label sort. Show all posts
Showing posts with label sort. Show all posts
Monday, March 19, 2012
Saturday, February 25, 2012
ADODB connection from inside EXCEL
I posted before, but it did not appear. Anyhow, I found
the answer -- sort of.
The problem is that I have two "identical" machines
running identical EXCEL spread sheet. One can do an
ADODB connection and the other can not. I could not
figure out what was different until I installed SQL Server
Client Services on the machine whose EXCEL did not work.
Now it works. Conclusion: Something has been added to
the register which is needed to support ADODB inside
EXCEL.
The question now is: How do I implement the change
without installing SQL Server? What is the minimum
installation that will enable EXCEL to do ADODB
connections?
Ken Jones
Is the missing package the ActiveX set? What isThe machines probably have a different MDAC level. I would check them using
the Component Checker which you can download at:
http://www.microsoft.com/downloads/...&displaylang=en
If you find they're different install the latest MDAC version on the older
system.
Mike O.
"Ken Jones" <kjones@.ziplink.net> wrote in message
news:0d2601c3d6d2$8262b8d0$a501280a@.phx.gbl...
the answer -- sort of.
The problem is that I have two "identical" machines
running identical EXCEL spread sheet. One can do an
ADODB connection and the other can not. I could not
figure out what was different until I installed SQL Server
Client Services on the machine whose EXCEL did not work.
Now it works. Conclusion: Something has been added to
the register which is needed to support ADODB inside
EXCEL.
The question now is: How do I implement the change
without installing SQL Server? What is the minimum
installation that will enable EXCEL to do ADODB
connections?
Ken Jones
Is the missing package the ActiveX set? What isThe machines probably have a different MDAC level. I would check them using
the Component Checker which you can download at:
http://www.microsoft.com/downloads/...&displaylang=en
If you find they're different install the latest MDAC version on the older
system.
Mike O.
"Ken Jones" <kjones@.ziplink.net> wrote in message
news:0d2601c3d6d2$8262b8d0$a501280a@.phx.gbl...
quote:
> I posted before, but it did not appear. Anyhow, I found
> the answer -- sort of.
> The problem is that I have two "identical" machines
> running identical EXCEL spread sheet. One can do an
> ADODB connection and the other can not. I could not
> figure out what was different until I installed SQL Server
> Client Services on the machine whose EXCEL did not work.
> Now it works. Conclusion: Something has been added to
> the register which is needed to support ADODB inside
> EXCEL.
> The question now is: How do I implement the change
> without installing SQL Server? What is the minimum
> installation that will enable EXCEL to do ADODB
> connections?
> Ken Jones
> Is the missing package the ActiveX set? What is
>
Subscribe to:
Posts (Atom)