ASP Classic - Column sorting with ASC and DESC - sorting

I have given a table and I need to add support (provide sorting function to sort the report table column record in Ascending and Decending direction) where the user select the Sort by option at the report table and choose either ASC or DESC.
Can you help on that..a simple example will do.

Personally i'd sort it client side using jQuery and the table sorter plugin

Related

Different Default ordering between ORACLE and PostgreSQL

I have a simple ORACLE Query which I should rewrite it to be run on postgresql with same output as below
Select X,Y FROM table_name order by Y
in case of I have only the below data in the table
Here you are the difference between PG and oracle in ordering the data
Do you have idea why such this difference occurs?
Different Default ordering
There is no such thing as "default ordering" - neither in Oracle nor in Postgres (or in any other relational database). Tables in a relational database represent un-ordered sets.
You are sorting on a column that contains the same value for both (all) rows. This is essentially the same as not sorting at all, because you have not defined any sort criteria to break those ties. Without an additional sort column the database is free to return the rows with the same sort value in any order it likes.
If you want the rows sorted by column x you need to include that column in the order by
select X,Y
FROM table_name
order by x,y;
or maybe you want order by y,x - it's not clear from your question (and the hardly readable screen shots)

Sorting results based on current year sales in multi-year table and creating rank column SSRS

I am newish to SSRS and I am trying to create a report where where each row displays sales for the selected year and the previous 2 years in separate columns. I would like to sort the results by the current year's sales and create a rank column and create a parameter allowing the user to choose the top N rows they wish to display. I see the tablix sorting tab which allows you to select an expression to sort by, but how would I specify that I want to sort by the sales for one year specifically? Or would I go about this by creating the rank column by that expression first then sorting the table by that rank column?
UPDATE: It is a SQL Server database and I can edit the SQL. For the columns I have storeID, storeName, Year, and Sales.

SQL developer single record view

I am currently using SQL developer to look through a table in a database that has many columns. It would be ideal if in the single record view to have the column names sorted? I have been unable to find any option to achieve this.
EDIT
The single record view occurs in a couple of places. This includes selecting a table in the list and then selecting the data tab. Then right click on a record.
This does not require writing any SQL.
The single record view is sorted:
SELECT COLUMN_NAME, COLUMN_ID
FROM user_tab_columns
WHERE table_name = 'YOUR_TABLE'
ORDER BY COLUMN_ID;
It is just sorted by the COLUMN_ID which corresponds to the order in which the columns were defined in the DDL statement(s) that created the table.
It is not sorted alphabetically (which is what you are probably after) - but you can get it sorted alphabetically if you order the columns alphabetically in the original DDL statement or by renaming the columns (to something else and then back to the original name and recreating indexes).

Cognos Report Studio Total of Column based on Distinct values of Column2

Cognos by default suppress duplicate/identical records. Duplicate rows do not appear in the report, but summaries are performed on all rows - including the duplicates that were eliminated.
To perform summaries on only the distinct rows, you must add the distinct key word when creating the summary definition. For example, the following summary:
Total(MyColumn)
Would become...
Total (distinct MyColumn)
But I would like Total of Column1 based on Distinct values of Column2. How to do this?
I assume your report is built on top of relational model.
The short answer to your questions is using FOR clause:
Using the AT and FOR Options with Relational Summary Functions
So you can do something like this:
Total(distinct MyColumn for Column2)
My question is why would you think distinct on one column is different from other column?
Cognos "eliminate" duplicate rows only if two or more rows are completely identical.
If one of the columns is different, then it's not a distinct row.
You can use grouping instead, which group together identical values on single column.

Sorting a table using a subrepot column in SSRS. Is this possible?

I'm using SSRS 2005. I've got a table with various inventory data. In one columns I've got a subreport that is designed to pull the date of the most recent Purchase Order based upon the product code of whichever row the subreport is in. This would be fine, however I'm now being asked to be able to sort by this date column. My assumption is that you cannot sort a column with a subreport in it, but I thought I'd ask. Is there any way to do this?
You can include the most recent purchase order value in your main report's dataset as a subquery like this:
SELECT *
,(SELECT TOP 1 PurchaseOrder
FROM Purchasing p
WHERE p.ProductCode = i.ProductCode
ORDER BY PurchaseDate DESC
) as LastPurchaseOrder
FROM Inventory
Then you can use that value to sort your table.

Resources