Display ROW As A COLUMN

Mar 15, 2008

I am JOINing a Table with a View, and the View can have multiple rows relating to the join condition(i.e. My view as 4 columns, and can look like the following:

A  B C D

A E F G

B H I J

I want this to look like -

A B C D E F G

B H I J

I want one row, but not one column, I need to maintain each value in its own column, withinin a single row. 

Doesn't matter to me if that transition happens in my View or as the outcome of my Join.

I've been looking at the PIVOT command, but that appears to only work with an aggrgrate function. I don't want to calculate/aggreagte anything, just combine my multiple rows in one.  

This is my VIEW stmt -

SELECT     [PKG ID] AS PKG_ID, [APPR GRP NAME], [USRID OF APPR], [APPR STATUS]
FROM         dbo.pkgapprovers
WHERE     ([APPR STATUS] = 'approved') AND ([APPR GRP TYPE] = 'E')

This is my Join stmt - set @sql = N'SELECT DISTINCT [PKG ID] AS PKG_ID, [ELM ACT] AS Action, [END EXEC DATE] AS "Exec Date", [COMMENT] AS Comment, [USRID OF APPR]

FROM [PkgAction]

FULL JOIN vw_PkgApprovals

ON PkgAction.[PKG ID] = vw_PkgApprovals.[PKG_ID]

WHERE 1=1'

 

Any thoughts....Thanks

 

View 7 Replies


ADVERTISEMENT

SQL Server 2008 :: Display A Column Alias As Part Of The Result Set Column Labels?

Feb 26, 2015

Is there a way to display a column alias as part of the result set column labels?

View 9 Replies View Related

How *NOT* To Display Header Column

May 19, 2004

Hi,

1. This is what SET NOCOUNT ON does:

-- SET NOCOUNT to ON and no longer display the count message.
SET NOCOUNT ON
GO
SELECT au_lname
FROM authors
GO


2. Now, is it possible and what is the statement to use if I don't want to display
the header column? au_lname. Thanks.

View 4 Replies View Related

Filter On One Column But Display Another

Jan 7, 2005

I have a date column and a value column. I want to display the value column based on the last date. MAX (Date)

I tried using MAX for the date column but that displays the last date.

Any Ideas?

View 5 Replies View Related

How To Display Column Descriptions?

Sep 18, 2004

Hello!

I am wracking my brain, trying to figure out how to return & display a column's description.

I work in Cold Fusion with SQL 2000 database.

My table name is "clients" and the column in question is "client_firstname"

The description of this column, as entered in Ent. Mgr, is "First Name"

If anyone can please help me, it would be very greatly appreciated!

Thanks!

Now for the details...

I am trying this:

----------------------------------------------------------------
<cfquery name="get_ext2" datasource="#application.dsn#">
SELECT
objname As 'Column'
, value As 'Description'
FROM
::fn_listextendedproperty
('MS_Description', 'user', 'dbo', 'table','client', 'client_firstname', default)
</cfquery>

<cfoutput>
"#get_ext2.Column#"
"#get_ext2.Description#"
</cfoutput>
----------------------------------------------------------------

... and it is returning this:

"" ""

In my debug output, the query result appears as such:

----------------------------------------------------------------
get_ext2 (Records=0, Time=16ms)
SQL =
SELECT
objname As 'Column'
, value As 'Description'
FROM
::fn_listextendedproperty
('MS_Description', 'user', 'dbo', 'table','client', 'client_firstname', default)
----------------------------------------------------------------

Haaalp!

Thanks....

Richard

View 1 Replies View Related

Conditional Display Of A Column

Apr 28, 2008

Would like to know if it is possiblefor any of you to suggest how to conditionally diaplay a Column based on the values of the other columns.
Here's my query
SELECT
[ProductionDay]
,DATEPART(wk,StartTime) AS WeekCount
,(AVG([RNTDuration])) AS AvgRNT
,MIN([RNTDuration]) As LeastRNT
,MAX([RNTDuration]) As WorstRNT
,dbo.fn_MinimumRNT_sp([ProgramNo],[Machine],[ProductionDay]) AS BestRNT
,dbo.fn_MinimumRNT(SubAssemblyNo,[Machine]) AS BestRNT_txt
,SUM([LoadingDuration]) AS LoadingTime
,[ProgramNo] AS ProgramNo
,COUNT(RNTID) AS PartsCount
,[SubAssemblyNo]
,[Sheetsize]
FROM [RPMS].[dbo].[List_MachineShopRNT]
where Machine = @iMachine and dateadd(month, datediff(month, 0, [StartTime]),0) = @dtMonthStartDate
Group by DATEPART(wk,StartTime), [ProductionDay],[Machine],[ProgramNo],[SubAssemblyNo],[Sheetsize]

Here I would like to Run the function dbo.fn_MinimumRNT_sp or dbo.fn_MinimumRNT if the ProgramNo is 100

Thank you

View 3 Replies View Related

How To Display Not A Actual Column

Jan 29, 2015

Query for output this result on Table C ?

========================================================
I have one table store below information, and other one table is store staff name and phone number. how to display of table c data by new column and using the key staff_code1=staff_id or staff_code2= staff_id or staff_code3=staff_id ?
---------------------------------------------------------

Table A
staff_code1,staff_code2,staff_code3

Table B
staff name
staff_id
staff_phone
-----------------------------------------------

Table C display in new column .
staff name-1 code1 staff name-2 code2 , staff name-3 code3
peter id-01 susuan id-03 david id-05

View 1 Replies View Related

Display Column Description

Jun 13, 2006

I have this easy sql for a drop down.

select code_value, desc1
from dbo.market_area_code
where code_value in ('1', '2', '4')

How can I add something to display something like

if code_value = '1' then display 'Blue'
if code_value = '2' then display 'Orange'
if code_value = '4' then display 'Red'

View 3 Replies View Related

Must I Display A Column In DataGrid To Reference It?

Oct 11, 2006

Hi,I have a DataGrid whose DataSource is an SQLDataSource. This SQLDataSource references a SQL Server table with an Identity column, named Id. The SQLDataSource has generated an Update statement for me, but this only works if the Id column is selected for display in the DataGrid, and has Visible = True. If not, then the @original_Id parameter to the generated Update statement has a value of Nothing, and the Update has no effect. So is there a way to enable the Update statement to work, without the user having to see the Id column in the DataGrid? Many thanks,Keith.

View 3 Replies View Related

Display Multiple Columns Into One Column

Feb 5, 2008

My first ASP.NET/SQL project. I'm creating an Asset Management DB. I wish to view the Asset number, the full name of the user it's assigned to and the Make and Model of each record in the DB. However assets are split into different categories e.g. monitors, PCs, Preinters etc. and they are all in different tables. The SQL below displays the asset number, Name of person assigned and the model of the asset.
SELECT Hardware.AssetNo, [User].FullName, MonitorModel.Model, PCModel.Model AS Expr1, PrinterModel.Model AS Expr2
FROM Hardware INNER JOIN
[User] ON Hardware.UserID = [User].UserID INNER JOIN
Model ON Hardware.ModelID = Model.ModelID LEFT OUTER JOIN
MonitorModel ON Model.MonitorModelID = MonitorModel.MonitorModelID LEFT OUTER JOIN
PCModel ON Model.PCModelID = PCModel.PCModelID LEFT OUTER JOIN
PrinterModel ON Model.PrinterModelID = PrinterModel.PrinterModelID
This outputs:-
Asset number     FullName     Model     Expr1     Expr2
00000                User Name   Model     NULL      NULL
00001                User Name   NULL      Model     NULL
00002                User Name   NULL      NULL      Model
However what i hope to acheive is output Model, Expr1, Expr2 into one column like so:-
Asset number     FullName     Model
00000                User Name   Model
Can i do this in the SQL or do i have to do it in my ASP.NET (VB) Page?
Using VSWD 2005 Ex Edition and SQL Server 2005 Ex Edition
Thank you for your replies

View 4 Replies View Related

How To Display Result Of Different Year In Different Column Instead Of Different Row?

Feb 7, 2006

I am trying to display component usage in January for the past year, if I want to display the year in different column, what should I do?
eg.
component_id   component_description   qty_used_on_2005_Jan   qty_used_on_2006_Jan
C58B0BDD       tape drive                             2                                              3
Currently I am using this sql:
select cast(year(date_complete) as varchar(10)) + ' Jan' as Year, component_id, component_description,sum(component_qty) as total_qty_used
from view_jobComponent
where month(date_complete) = 1group by component_id, component_description, cast(year(date_complete) as varchar(10)) + ' Jan'order by component_id, component_description
which I will get something like this:
Year          component_id   component_description   total_qty_used
2005 Jan    C58B0BDD       tape drive                             22006 Jan    C58B0BDD       tape drive                             3

View 9 Replies View Related

Change Results In Column To Display Different

Jan 30, 2004

I have a column in the following select startement called displayvalue. Displayvalue is a varchar column. Primary everything entered into this column is numeric, but there are times when NR is entered. In the select query if it sees NR, I would like to have NR changed in the resultset to NULL or blank. NR doesn't come up all of the time, but I have not idea how to do this in the select statment.

Here goes..

SELECT SAMPLE.SAMPLEID, SAMPLE.U_WORKORDERNUMBER, SAMPLE.U_SAMPLEDATETIME, SDI.PARAMID, SDI.DISPLAYVALUE
FROM SAMPLE SAMPLE, SDIDATAITEM SDI
WHERE ( (SAMPLE.SAMPLEID = SDI.KEYID1) AND
(SAMPLE.U_WORKORDERNUMBER = '0060') AND (SAMPLE.U_SAMPLEDATETIME > '31-DEC-2003') AND (SDI.PARAMID = 'BOD') )
ORDER BY SAMPLE.SAMPLEID ASC, SDI.PARAMID ASC

View 1 Replies View Related

Select And Display Part Of Column

Dec 5, 2013

How do I only display a part of data from the column ?

Lets say emp_id is E3456 and all i want to display is 3456 without that E?

View 2 Replies View Related

Multi Column Display In A Report??

Nov 30, 2007



I have a table with a data cell which is printing top-to-down

1
2
3
4
5
6
7
8

I want it to print like

1 2 3 4 5 6 7

How to do this??

The cell is in a group detials sections. and I am using Reporting Services 2000 with VS.NET 2003

Thanks in Advance

View 12 Replies View Related

How To Display 2 Columns Of Data In 1 Column?

Aug 16, 2007


How to display 2 columns of Data in 1 column?

If I use like this

Select Names, 'myData' from emp

The output is:
Name1 myData
Name2 myData
Name3 myData

But, I need to display like this

Name1
myData
Name2
myData
Name3
myData

please advise

View 5 Replies View Related

How To Display Column From Inserted Table

Jul 31, 2007

Hi all,

I have created a trigger in SQLExpress which looking for any insertion to a specific table in a database:

Create Trigger Tg_Insert on [tablename]
FOR Insert
AS
Select * FROM Inserted
---------------------------------------------------------
Assume there is nothing wrong with this trigger as I have already checked the output with Query tool.
My question is how can I display the newly inserted data to the client? In my case, Console application.
I want to do something like Console.WriteLine("data from inserted table here");
How can I achieve this? FYI, I'm using VS2005 with sqlexpress 2005.
Thanks in advance.

Regards,
SHAH

View 11 Replies View Related

Display Database Column In Alphabetical Order

Mar 12, 2007

Hello
I know how I can display a list of names in alphebetical order on my website:
Select L as [Last Name]
From  Name_CatEWhere Education = 'yes'Order ByLName ASC
However, to make things a little more orginised I would like to view my database table column in alphabetical order also, but ithie code does not work within my database.
What do I need to change in the following code, to view my database table column in a-z order?
 SELECT LName FROM Name_CatEORDER BY LName ASC
Thanks
Lynn

View 1 Replies View Related

Display A Table From A Gridview But Every Column Has Its Own Where Arguments??

Mar 10, 2008

Hi,please help me, i have a data driven site,i need to display a table who look like this Name            Total            Used            RemainingA                    10                5                    5B                    20                13                  7C                    12                                    12  if you would look on the field of total, used and remaining, they look like an excel formula which is total - used = remaining or vise versa.but the problem in this table is the database, it look like thisname         On/OffA                  1A                   1A                    0and soon....... B                     1B                     0B                     1and soon.... until C so how do i count the total, is the number of A's or B's or C's in the whole database then Group By the 'name' fieldthen how do i count the used is the number of ON in the On/Off field while remaining is counting the Off,so my question is i have RUN this using 3 different gridview each has its own datasource, that look like this for the used  select name, count(on/off)
from myTable
where on/off = 1
group by name for the  remaining select name, count(on/off)
from myTable
where on/off = 0
group by name and for the total, just used the same Select but without the where clause,i get this problem when the field "used"  (please refer from the 1st table) it has a blank value, which is because my data base show that in deed name "C" has not been used, but eve though it should show '0' instead of a blank,  so how can i do that???please help me, thanks 

View 6 Replies View Related

Display Output Where Integer Value Is Column Data

Dec 1, 2011

I want to display the following output where integer value is column data.

{[Advertiser].[AdvertiserKey].&[4000],
[Advertiser].[AdvertiserKey].&[4001],
[Advertiser].[AdvertiserKey].&[4002],
[Advertiser].[AdvertiserKey].&[4003],
[Advertiser].[AdvertiserKey].&[3661],
[Advertiser].[AdvertiserKey].&[3662]
}

View 4 Replies View Related

How To Display The Column Description In Query Analyser

Jun 1, 2004

Hello All.

I have created a table with short name as the file name but have entered the description in the column box (when creating a new table - see attached). I would like to show this description information in query analyser. Can this be done? I used sp_help <table name> but it doesn't show the description.

Please advise. Thank you.


Best regards

View 2 Replies View Related

Formatting A Column Display With Dollar Sign

Feb 24, 2014

How to implement the display of a dollar sign for an output in a query...

View 5 Replies View Related

Display Column Data In Multiple Lines

Apr 14, 2014

I have data like this

TableA

ID JunkData
1 1234jdueakj34jfjj4
2 345j5uttuvj5575jkf
3 sjhsdfk283ncfkjsf9

I need the Result to display like this. Split the JunkData Column Data in multiple lines, each line should contain 5 characters.

ID JunkData
1 1234d
ueakj
34jfj
j4
2 345j5
uttuv
j5575
jkf

View 2 Replies View Related

Transact SQL :: Display Different Table Having Same Column With Different Data

Sep 25, 2015

I am having two table i.e( tbl_oldEmployee , tbl_NewEmployee ),which is having Column name Employee Name and City same in both table but inside column data is different in different table.but i want to view the Employee name and City from tbl_NewEmployee to tbl_oldEmployee which is having EmployeeId common with tbl_oldEmployee extra record also required (i.e  tbl_NewEmployee having 6 record  and tbl_oldEmployee having 10 record,so i need to display data from  tbl_oldEmployee but first 6 record which id match with tbl_NewEmployee id should be replaced and extra data from tbl_oldEmployee also display).

View 3 Replies View Related

DISPLAY COLUMN GRANDTOTALS IN A MATRIX REPORT

Mar 21, 2007

Hi there...

I have a matrix report within a list so it functions as a report with dynamic columns.

Matrix a:

a b c d e

x 1 2 4 9 12 <NEED SUBTOTAL across Columns for row x>

y 6 2 4 5 9 <<NEED SUBTOTAL across Columns for row y>

TOTAL <need totals going down rows and need a grand total>



Remember the number of rows and columns are dynamic so I have NO CLUE how to add a column and display it if and only all the columns have been displayed ...sort of like a COLUMN and ROW footer for a matrix report.



Any help will be appreciated

thank you

Prashanth Prasanna

View 1 Replies View Related

How To Combine Two Cloumns And Display As One Column In UI ? How To Write Query For This?

Mar 14, 2008

I have 2 Columns FirstName and LastName but i need to show it in UI as User Name ,that means i need to combine both First Name and Last name and display both as 1 field namely UserName ,How to query tht ? What shld i use?

View 2 Replies View Related

Display First Date If Split Into A Year And Month Column?

Mar 27, 2012

How can I find the first date if the date is split into a year and month column?

I thought of using the Min function, which would work for the year column, but it would probably just return a 1 everytime in the month column.

View 2 Replies View Related

Change Display Of Result Set From Showing As Rows To Column As One Or More

May 13, 2014

I am interested in changing the way that data is displayed in my result set.Essentially I want to display a selection of rows (1 to n) as columns, the following diagram explains my intentions.Perhaps one of the greatest challenges here is the fact that I do not have a concrete number of rows (or BIN numbers). Each stock item could be stored in one or more BINS, which I will not know until running my query.

View 2 Replies View Related

SQL Server 2012 :: Display Data In Blocks (Column Name)

Jan 29, 2014

I want to display data in block. Below is the Create,Insert Script and format of desired output.

CREATE TABLE [dbo].[Test_AA](
[CounterpartID] [varchar](2000) NULL,
[CounterpartName] [varchar](2000) NULL,
[SATName] [varchar](2000) NULL,
[NameOfBO] [varchar](2000) NULL,

[Code] ....

Result Should be like This :

ID:17388
Name:Scottie Berwick
SATName:Scottie Berwick
NameOfBO:
SATAccountNumber:

[Code] ....

View 4 Replies View Related

T-SQL (SS2K8) :: Query To Display Different Values From Same Column In Same Table?

Sep 18, 2015

I have a table with a column AttributeNumber and a column AttributeValue. The data is like this:

OrderNo. AttributeNumber AttributeValue
1.-Order_1 2001 A
2.-Order_1 2002 B
3.-Order_1 2003 C
4.-Order_2 2001 A
5.-Order_2 2002 B
6.-Order_2 2003 C

So the logic is as follows:

I need to display in my query the values are coming from Order_1, means AttributreValues coming from AttibuteNumbers: 2001,2002,2003...and Order_2 the same thing.

Not sure how to create my Select here since the values are in the same table

View 2 Replies View Related

Select Statement - Column To Display Full Name Is 99 Characters

Apr 14, 2015

Select statement. In my database i am using the employee table. I need my first column to display your full name is 99 characters. so like if the employee is john smith it would display Your Full Name Is 9 characters (including the space).

View 2 Replies View Related

Reporting Services :: How To Display Month Column As Varchar

Jun 1, 2015

I have a doubt ,while doing report, I have month column, I have passed 11 in  month parameter, but I want to display month column as NOV not 11. 

View 2 Replies View Related

Help Required On Mouse Over Display On Stacked Column Charts

Aug 9, 2007

Is there a way to get markers on the top of each graph of a stacked column chart?
Also i need to display a label when the mouse points over each of the marker, as well as each partition of the graph. Getting the tooltips to work might b a help but it is not working for me. I got a reply that enabling the mouse over in the report viewer might help, but i dont know how to enable

View 1 Replies View Related

Integration Services :: Derived Column Expression - Display Only Name?

Jun 16, 2015

How can i write expression for below input?

1858;# 1234;#Chun  Yang

I want to display only name.

View 2 Replies View Related







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