Showing posts with label sqli. Show all posts
Showing posts with label sqli. Show all posts

Friday, March 23, 2012

order by Desc,third data

in sql
I use "select top 3 from.....order by (tablename) desc,that can give 3 datas
but i want third data to my program
So i use other function:
SELECT TOP 1 'answer'=AAA.A FROM
(
select distinct top 3 'A'=month FROM dataTable
where month < '200511'
ORDER BY month DESC
) as AAA
ORDER BY AAA.A
But ,how can i do fast?
Can use other function?
This should be very fast if you have the right indexes. Do you have an
index on Month?
Andrew J. Kelly SQL MVP
"Sam_Chou" <SamChou@.discussions.microsoft.com> wrote in message
news:75531889-BD27-4AAF-AA1B-86A081FF1B54@.microsoft.com...
> in sql
> I use "select top 3 from.....order by (tablename) desc,that can give 3
> datas
> but i want third data to my program
> So i use other function:
> SELECT TOP 1 'answer'=AAA.A FROM
> (
> select distinct top 3 'A'=month FROM dataTable
> where month < '200511'
> ORDER BY month DESC
> ) as AAA
> ORDER BY AAA.A
> But ,how can i do fast?
> Can use other function?
|||sorry...I have't an index on Month.
"Andrew J. Kelly" wrote:

> This should be very fast if you have the right indexes. Do you have an
> index on Month?
> --
> Andrew J. Kelly SQL MVP
>
> "Sam_Chou" <SamChou@.discussions.microsoft.com> wrote in message
> news:75531889-BD27-4AAF-AA1B-86A081FF1B54@.microsoft.com...
>
>
|||Well then it will scan the table each time. If you need to find the top 3
by month on a regular basis then you need an index on that column.
Andrew J. Kelly SQL MVP
"Sam_Chou" <SamChou@.discussions.microsoft.com> wrote in message
news:BFE52A0A-1F72-44EC-B599-5074816B5575@.microsoft.com...[vbcol=seagreen]
> sorry...I have't an index on Month.
> "Andrew J. Kelly" wrote:

Wednesday, March 7, 2012

Oracle OBJECTs

Hello,

Has any one used object-oriented features of PL/SQL?

I know you can do something like the following.

CREATE TYPE employee AS OBJECT (...)

My biggest concern is performance: Do the objects in Oracle negatively affect performance? Anything else I should be aware of?

Thanks in advance,
EdwardHello Edward,

when you use TYPE for accessing or handling datas the performance will not change. Thats what we find out in our projects.
The benefit of using types is accesing complex datas very handy and often with one select.

Regards

Manfred Peter
(Alligator Company)
http://www.alligatorsql.com