Showing posts with label item. Show all posts
Showing posts with label item. Show all posts

Wednesday, March 28, 2012

ORDER BY Question

Item Quantity
I1 10
I2 7
I1 5
Assume that is the Data.
I want it ordered by Quantity FIRST and then show the same Item again
if it exists.
How can I display it in this way
Item Quantity
I1 10
I1 5
I2 7
P.S Please do not say "ORDER BY Item, Quanity DESC"I'll guess you want to order by max(Quantity) for the same item.
select
T.Item,
T.Quantity
from T
join (
select Item, max(Quantity) as maxQuantity
from T
group by Item
) as Tmax
on Tmax.Item = T.Item
order by maxQuantity desc
[Not tested, but I hope you get the idea]
Steve Kass
Drew University
rythm wrote:

> Item Quantity
>I1 10
>I2 7
>I1 5
>Assume that is the Data.
>I want it ordered by Quantity FIRST and then show the same Item again
>if it exists.
>How can I display it in this way
>Item Quantity
>I1 10
>I1 5
>I2 7
>P.S Please do not say "ORDER BY Item, Quanity DESC"
>|||Thanks that did work.
After looking at it, it seems so simple.
I couldn't even think of performing it in that ordersql

Wednesday, March 21, 2012

ORDER BY

hi,

i' ve Drop Down List with sorted catagory and Data Grid that cange according to selected item in drop down list ... i need to send the selected item as value to SELECT statment, so i 've send (option) as a value

"SELECT [userstory].* FROM [userstory] WHERE ([userstory].[rel_id] = @.rel_id) ORDER BY @.options "

but there is an error:

The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a column position. Variables are only allowed when ordering by an expression referencing a column name

You should order by a column name and not a param. Soif your field is payDate in your DB then you would do order by payDate .|||

thanks for answering

bt if i need to use variable as ordered by coz i've send for 1st time order by status 2nd order by risk .. an so on..

can i?

Monday, March 12, 2012

Oracle SQLPlus Worksheet

When I run an SQLPlus query, the displayed width of each column is the width of the data item. This means that the column header for many fields is truncated. How do I override this default width in order to make the entire column header appear without being truncated. An example is below. The last column is titled DESTINATION, but only DES shows.

BAG_TAG_N ORI DES
--- -- --
3UA233468 TUL ORD
3UA233468 AVP ORD
3UA233468 ORD MLIOriginally posted by mryan916
When I run an SQLPlus query, the displayed width of each column is the width of the data item. This means that the column header for many fields is truncated. How do I override this default width in order to make the entire column header appear without being truncated. An example is below. The last column is titled DESTINATION, but only DES shows.

BAG_TAG_N ORI DES
--- -- --
3UA233468 TUL ORD
3UA233468 AVP ORD
3UA233468 ORD MLI

try: set linesize 120