SQL Server :: How To Show Two Columns One Is The One Will Contain The Distinct Values From 'col'

Mar 30, 2011

I have a table 'tbl' and a column 'col'. The elements are like 1,1,2,2,2,3,4,4. Now I want to show two columns one is the one will contain the distinct values from 'col' like 1,2,3,4.... and second will contain the count for each of them like for above case it will be 2,3,1,2.

View 1 Replies


Similar Messages:

Select Distinct And Include Non-distinct Columns?

Apr 20, 2010

I would like to select a distinct query based on three fields and display the rest of the fields. For example,

I have firstname, lastname, address, city, state and zip, but I only want to use the distinct on these fields first and last name. However when i use the distinct function I get a distinct on all the selected rows. I just want to distinct firstname and lastname and display the other fields. for example,

Mary Smith New York
Mary Smithy New York
Mary Smith Maine

I would like the result to be:

Mary Smith New York
Mary Smithy New York

I don't care about Mary Smith Maine, because i am only using the distinct for "Mary Smith" firstname and last name and showing the city.

View 15 Replies

SQL Server :: How To Use Distinct On A Single Column From A List Of Columns

Jan 21, 2011

I would like to know if there is a way that I can use DISTINCT on one column's values but need to show other columns where the value of the DISTINCT column is equal to another table's column

View 7 Replies

SQL Server :: How To Select All Columns Of Table But To Distinct By One Column

Dec 29, 2010

How can i select all columns of table but to distinct by one column? i am tryin to figure it out without success, i know how to make distinct (select distinct column from table, but i need all the values from the table and to distinct by Delcompany.

my line is:

[Code]....

View 13 Replies

SQL Server :: How To Get Distinct Column Name Which Are Having Distinct Values In The Column

Feb 4, 2011

I have one table(tableName is getDetails and having three column ID, Name, City)

View 6 Replies

SQL Server :: How To Get Distinct CSV Values

Jan 17, 2011

Here's my current table data.

AccountNumber Product
00505871 Product1
00505871 Product2
00503297 Product3
00900004 Product4
00505871 Product3
00514884 Product3
00503297 Product2
00505871 Product1

How can I achieve following result.

AccountNumber ProductString
00505871 Product1,Product2,Product3,
00503297 Product2,Product3
00900004 Product4
00514884 Product3

View 13 Replies

SQL Server :: Query To Return Conditional Counts Both Distinct And Non Distinct?

Sep 30, 2010

I have the following table structure:

[code]....

The following query returns the default recordset:

[code]....

View 4 Replies

DataSource Controls :: How To Select Multiple Columns With Distinct Key Word

Jan 2, 2010

there are multiple rows with same SubContact_No and with same value of some columns. for a single column I am firing query like

Select distinct (Financial_Status) from mtblSub_Contract where SubContract_No=@SubContract_No";

it's working fine.... (it's ok with a Single column)

But Now I need multiple columns value so how to query for this.

Select distinct (Financial_Status, colums2, column3) from mtblSub_Contract where SubContract_No=@SubContract_No"; is not working

So how to do that.

View 5 Replies

SQL Server :: How To Show Other Columns With Aggregate Function

Nov 15, 2010

In my query , I have an aggregate function and other columns and a Group By clause where there is a column which I need to show without placing it in Group By clause.

View 2 Replies

SQL Server :: Show Other Columns With Aggregate Function?

Jan 7, 2011

In my query , I have an aggregate function and other columns and a Group By clause where there is a column which I need to show without placing it in Group By clause.

View 7 Replies

Show Distinct Selection In Webform?

Feb 21, 2010

If I use a regular distinct selector with MySQL and show the results in a repeater I can show the the data in the webform with the following code.

<%# DataBinder.Eval(Container.DataItem, "posted") %>

But If I use this code:

"SELECT DISTINCT mid(posted,6,1) ORDER BY posted DESC"

I get the following error trying to use the code above.

DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'posted'.

So how do I get the data I've collected with the "DISTINCT mid"-selector to appear in the webform?

View 1 Replies

ADO.NET :: Distinct Values From A Column In Datatable?

Sep 21, 2010

I have a datatable dt with 4 columns. I want to retrieve only distinct values from column1 of datatable.

How can I achieve this using c# code?

View 3 Replies

ADO.NET :: How To Return DISTINCT Values Of Person.ID

Oct 31, 2010

This is my query

Dim s_Person = From Person In db.People Join ProspectStatus In db.ProspectStatus On Person.Id Equals ProspectStatus.Prospect_ID Where (Person.Organization_ID = s_Organization_ID)Select Person.

I only want to return DISTINCT values of Person.ID. Right now, it returns the same person multiple times because there are several entries in the status table.

Dim s_Person = From Person In db.People Join ProspectStatus In db.ProspectStatus

View 1 Replies

Web Forms :: Distinct Values In DropdownList?

Jul 15, 2010

i'm binding data to ddl from database.i'm selecting one column from database table to bind.In that column there may be items with same name.but when selecting in ddl there must be no same values.

View 4 Replies

ADO.NET :: Linq To Sql Using Distinct On Individual Values?

Jul 29, 2010

I have a database that is filled with documents. In the database there is the documents id, name and version. Two documents can have the same name and id but are seperated by different versions.For instance there can be two entries, id: A44, name: Dilbert was here. But they are version A and B.When retrieving these to a listview I wish to limit the documents shown to only one version. Doing so means that I am only to show one document with the same id. I only get the id and name to show in the listview so I thought that distinct might do the trick. But since the name can change throughout different versions this was no good.Basically I wish to retrieve all documents but with distinct id. How do I achieve this?

View 10 Replies

Sql Server - Gridview Highlight Max Values In Multiple Columns?

Mar 29, 2011

I have a gridview that shows, for example, a baseball team's statistics. It's a standard sports stats grid - the rows show statistics for each player and the columns show the specific stat for the each player.

Easy enough so far. But what I would then like to do is style (highlight or bold) the Max or Min (the team leader) of each stat column. For example, Player A may only lead in one or two categories, so we cannot style the entire row. If Player A just leads the team in strikeouts, I just want to style the number of strikeouts he had (THAT cell only).

What's the best way to handle this? Make SQL Server do all the work and in effect, rank EVERY stat of each player, effectively doubling the number of columns (e.g. col: AB, col: ABRank). Or do I let the rowdatabound event of the gridview handle this?

If I chose the latter, I think I would get the Max of every statistical category from the datatable before binding (e.g. store them in a local variable) then on rowdatabound, if they match the value, apply the style.

View 3 Replies

Linq To DataTable Not Producing Distinct Values?

Oct 19, 2010

I have a datatable which has been dynamically generated from FoxPro tables using a UNION Select statement. e.g.

SELECT * FROM x UNION SELECT * FROM y UNION SELECT * FROM Z ORDER By v_alue1

This produces a datatable with about 100 rows, each containing many fields, one of which is c_olor. From this datatable, I would like to select the distinct colors and then output in a dropdown.

I have a public class Color which just has one property which I can then use as the DataTextField and DataValueField for the dropdownlist

[code]...

However this never results in the distinct colors.

I have searched and searched for what I am looking for, and this seems to be one of the methods to produce a distinct set of results, but this and the others do not work.

My reasoning behind getting the colors this way, is that I need to get various other distinct values from the same UNION SELECT datasource, so would just do one DB call, cache the results, and then just used this cached datasource to retrieve all my distinct values.

View 2 Replies

Crystal Reports :: Distinct Combination Of Two Values?

Dec 17, 2010

I have distinct value combinations of two values.i cannot achive in sql why beacause ,here crystal report having grouping options and output will going to print in a foote..

Sample format crystale report

SNo Name TranID
1 Guru 18
2 Inbaa 19
3 Guru 20
4 Inbaa 19
------------------------------------
Total Name : 3 Tran ID :3
------------------------------------

Name inbaa with Tran ID 19 is duplicate ..

View 2 Replies

Web Forms :: How To Bind Distinct Values To DropDownList From DataSet

Oct 6, 2010

I'm trying to bind a dataset (where the data is coming from a webservice) to a dropdownlist; the problem is that I'm getting duplicates in the list... how can I display distinct values only:

[Code]....

View 5 Replies

ADO.NET :: Fetching Only Distinct Values Of Particular Column To Assign To Dropdown List?

Nov 19, 2010

As I kept my fetched datatables into session and accessing it on another page there I am

wroking on datatable to fetch only distinct values of particular column to assign to dropdown list.

View 1 Replies

Show Several Columns In Datasource As Autogenerate Columns In Gridview?

Jan 27, 2011

I have a datasource, which includes many columns, idealy, I need use a gridview to show:

1) first 3 columns: template fields, these fields depends on values in some columns of datasource. I use template fields, hard coded. works fine.

2) the other columns. This is I do not know how to do it. In the data source, there are about 10-20 columns data, each time, the # of columns of the data varies. idealy, I need show each of them as a seperated column in gridview. The entire data source may have 30 columns, but some of them are used in 1), and I only want show these 10-20 columns in gridview. Some columns in data source, I may not use them at all. is there a way to do this? or have to seperate them as a detail view style UI?

View 1 Replies

Data Controls :: Make Columns Hidden In GridView And Access Their Values Server Side

Feb 24, 2014

I want to get the values from the Invisible rows from my gridview.  here is my code.

<asp:GridView ID="gvTeam" runat="server" Width="900px"
AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px" CellPadding="4">
<Columns>
<asp:BoundField DataField="FULLNAME" HeaderText="NAME" />
<asp:ButtonField DataTextField="EVALUATION" HeaderText="EVALUATION"
Text="EVALUATION" CommandName="select" >

[Code]...

View 1 Replies

Data Controls :: Separate Out And Search Comma Separated Values In Database Columns In SQL Server

Dec 27, 2012

I have one table in sql server called student_info

In this table keys kills column contain value like below

'c,c++c#'
'c++,c,c#'
'c,c++,c#,asp.net'

etc...

I want to search the student information based on keyskills like naukri

1.Any keyskills from textbox1
2.All keyskills from textbox2
3.Except keyskills from textbox3

When I enter c,c++ or c++,c in textbox1 then it will dispaly all the student whose have c,c++ keyskill

How to achieve this.

View 1 Replies

SQL Server :: Get Distinct When Having Row Id

Oct 13, 2010

I have tableone:

rowid pid gid dis
1 1222 aa dd
2 1222 bb cc
3 1222 cc dd
4 1331 vv cc
5 1331 cc zz
6 1414 zz cc
5 1414 xx zz

I need get distinct pid with rowid together. select * distince pid from tableone However, I get error: select rowid, distinct pid from tableone? Is any way to work out this one?

View 4 Replies

Web Forms :: Values Of 1 Field In 4 Columns On UI / Display As Checkbox Values On UI?

Feb 8, 2010

I hv a filed in db having 60 values. I want them to be displayed as checkbox values on my UI.but i want those checkboxes as 15 values in 1 column.15 in 2nd col.15 in 3rd col.and last 15 in 4th coln. how to do it?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved