Translate Rows To Columns - SQL2000

Apr 30, 2008

Hi

I want to translate the following



SERIALNO TYPE AMOUNT
1111 1 251111 1 5 1111 1 7 1111 1 3 1111 1 101111 3 1 1111 3 2 1111 3 4 1111 3 3
2222 0 1
2222 0 7
2222 0 1
2222 1 5
2222 1 1
2222 1 2
2222 1 3





to output in the following format


SERIALNO SUM of MIN SUM of MAX
1111 50 10
2222 9 11
For each SERIALNO I want to sum the AMOUNT, spliting the columns into 2 based on TYPE
There are only ever 2 values for TYPE for eachs serial no.
I don;t need to track the value of TYPE.
I assume you would use a MIN & MAX function but Im not sure how to write this into a view.

thanks...

View 11 Replies


ADVERTISEMENT

Transact SQL :: Strategy To Translate Column Data Into Distinct Rows

Aug 27, 2015

I am writing a query where I am identifying different scenarios where data changes between one week and the next. I've set up my result set in the following manner:

PrimaryID       SKUChange              DateChange         LocationIdChange        StateChange
10003             TRUE                       FALSE                  TRUE                          FALSE
etc...

The output I'd like to see would be like this:

PrimaryID        Field Changed          Previous Value      New Value
10003             SKUName                 SKU12345           SKU56789
10003             LocationId                 Den123               NYC987
etc...

The key here being that in the initial resultset ID 10003 is represented by one row but indicates two changes, and in the final output those two changes are being represented by two distinct rows. Obviously, I will bring in the previous and new values from a source.

View 3 Replies View Related

Arranging Data On Multiple Rows Into A Sigle Row (converting Rows Into Columns)

Dec 25, 2005

Hello,
I have a survey (30 questions) application in a SQL server db. The application uses several relational tables. The results are arranged so that each answer is on a seperate row:
user1   answer1user1   answer2user1   answer3user2   answer1user2   answer2user2   answer3
For statistical analysis I need to transfer the results to an Excel spreadsheet (for later use in SPSS). In the spreadsheet I need the results to appear so that each user will be on a single row with all of that user's answers on that single row (A column for each answer):
user1   answer1   answer2   answer3user2   answer1   answer2   answer3
How can this be done? How can all answers of a user appear on a single row
Thanx,Danny.

View 1 Replies View Related

T-SQL (SS2K8) :: Rows Into Columns - Remove Duplicates And Variable Rows

Aug 5, 2014

I managed to transpose rows into columns.

;WITH
ctePreAgg AS
(
select top 500 act_reference "ActivityRef",
row_number() over (partition by act_reference order by act_reference) as rowno,
t3.s_initials "Initials"
from mytablestuff
order by act_reference

[code]...

But what I would love to do next is take each of the above rows - and return the initials either in one column with all the nulls and duplicate values removed, separated by a comma ..

ref, initials
Ag-4xYS
Ag-6xYS,BL
Ap-1xKW
At-2x SAS,CW
At-3x SAS,CW

OR the above but using variable number of columns based on the maximum number of different initials for each row.this is not strictly required, but maybe neater for further work on the view

ref, init1,init2
Ag-4xYS
Ag-6xYS,BL
Ap-1xKW
At-2x SAS,CW
At-3x SAS,CW

View 6 Replies View Related

Turn Columns Into Rows And Rows Into Columns

Jan 24, 2008

I have a report which is a list of items and I display everything about the item. It is great. My report table in the layout tab is simple. Header,Detail,Footer. Each Item has 65 columns. The number of items (rows) vary upon what you want to see. Example data.
Item#, Description, CaseSalePrice, Cost, BottleSalePrice, Discount
123, Grenadine, 100.00, 75.00, 15.50, 2.00
456, Lime Juice, 120.00, 81.00, 17.25, 2.00

There could be 1 item or 4000 items.

What I want to see is.

Item # - 123, 456
Description - Grenadine, Lime Juice
CaseSalePrice - 100.00, 120.00
Cost - 75.00, 81.00
BottleSalePrice - 15.50, 17.25
Discount - 2.00, 2.00

What I am actually doing is running this the top example and saving to excel. Then copying the sheet. Creating a new sheet then doing a paste special transpose and this gives the users what they want to see.

I want to grab that table object in the report layout tab and twist it 90degrees so the header is on the left, detail is in the middle and the footer is on the right. It would be perfect.

The dynamic column need is really the problem here. I never know how many items will be in the report. They all have the same basic information like description and pricing.

I am all out of creative ideas, any help would be appreciated.

View 6 Replies View Related

Translate Function

Nov 8, 2007

Can i use Translate function in sql server query? How i ll use? In my oracle, i m using a Translate function, but i want to run that in sql server. How to do that?

View 3 Replies View Related

Translate Function?

Jul 20, 2005

Hi allIs there a TSQL function like Oracle's Translate function? Where:Translate('13,000Miles','abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP QRSTUVWXYZ, ',' ') wouldreturn '13000'?I'm trying to extract a number from a string. REPLACE doesn't quite dowhat I want.Thanks

View 1 Replies View Related

How To Translate Into SSIS??

Mar 12, 2007

Hi everyone,

My current dutie is translate Vb code into SSIS. The following structure is getting me totally crazy:

sql = "SELECT * FROM TABLE1 WHERE FIELD = XXXX"
rs.execute sql
WHILE NOT RS.EOF
STUFF
ANOTHER SELECT AND ANOTHER LOOP
...
...

INSERT AND DELETE STUFF


END WHILE

Which is the best method in order to reach this goal? I'm trying to by means of OLEDB Source Editor connected to Script Component Task on data flow layer but I'm stuck with this.

I don't want to do cursors or something like that with T-SQL.

Thanks in advance for your inputs/help and regards,

View 8 Replies View Related

Can I Use Translate In Sql Server,is It A Keyword

Oct 3, 2006

im trying to find the equivalent of the below oracle code in sql server.But to my knowledge i feel "translate "is not supported by sql server. so please send me the equivalent sql server query for this.SELECT 'http://ploft.com/ploft?y='||translate(comp,' ','+')||',+'||translate(california,'','+')||',+'||ca||'+'||pzINTO :ls_MAP FROM project WHERE portno=:dbno;

View 3 Replies View Related

Translate Numbers To Words?

Aug 30, 2013

In the below query i need to display the amount in words also. How to do that in sql server 2008 R2?

SELECT ROUND(SUM(BM.CONCESSION_AMOUNT_M),2)AS[TOTAL_CONCESSION_GIVEN] FROM BILL_MASTER BM

View 3 Replies View Related

Translate Sql Statement Into SQL-92 Standards

Jul 20, 2005

Can anyone help me translate this statement from using the legacyouter joins to the SQL-92 standards?Select CA.* From Customer C, Shipper S, Customer_Order CO,Cust_Address CA Where CA.Customer_ID =* CO.Customer_IDand CA.Addr_No =* isnull(S.Ship_To_Addr_No,CO.Ship_To_Addr_No)and C.ID = CO.Customer_IDand (S.Shipped_Date between '1/1/2003' and '12/31/2003')Try as I may, I simply can't find a working left, right, or full outerjoin statement that would give me the same results as the abovestatement gives. I thought this was suppose to work but don't knowwhy it doesn't. Anybody care to try or perhaps tell me why thestatement below doesn't work:Select CA.* From Customer C, ((Customer_Order CO left outer joinCust_Address CA on CA.Customer_ID = CO.Customer_ID) left outer joinShipper S on CA.Addr_No =isnull(S.Ship_To_Addr_No,CO.Ship_To_Addr_No)) Where C.ID =CO.Customer_IDand (S.Shipped_Date between '1/1/2003' and '12/31/2003')Thanks,Tony

View 4 Replies View Related

How To Translate Varchar Into Varbinary?

Apr 3, 2007

Hi everyone,



We're trying to migrate a varchar field from Sql2k to varbinary in a sql25k through a dtsx package. We get an error which tell us: "data will be lost".



Does anyone have any idea about that?



Thanks for your time and inputs,

View 1 Replies View Related

How To Translate Oracle Decode

Aug 2, 2006

Hi,

How to translate oracle Decode without changed code I mean:

I have one application and instead to change all decode to case when I would like just replace decode for dbo.decode, so I

Wrote this function

select dbo.fnDecode( 1 , 2 , 3 )

first parameter always int, and the others parameters could be char, int or float.

I would like to test first value and return second or third value

-> sql_variant for all parameters, ok

but I can use + or -

I can't do this

select dbo.fnDecode( 1 , 2 , 3 ) + dbo.fnDecode( 1 , 2 , 3 )

If I put cast ok, but I is there another way, overload this call?

With clr doesn't work, because Sql Server doesn't accept function overload calls from C#



Any ideia????????????????????

cheers,

View 4 Replies View Related

How To Translate DTSStepScriptResult_DontExecuteTask Into SSIS?

Mar 15, 2007

Hi everyone,

We're struggling ourselves with this and we are stuck.



Which is the equivalent for a SSIS in a Script Task component on CONTROL FLOW layer?

Main = DTSStepScriptResult_ExecuteTask


Thanks for your input and regards,

View 4 Replies View Related

How To Internationalize And Translate RDL Files

Aug 10, 2007

Hello,

I€™m new to this forum and my knowledge about RDL is very limited. We are developing software localization tools and some of our customers have requested a solution to translate RDL files.

Our tool has a generic XML parser so I reviewed the RDL documentation but didn€™t found any information about which XML elements do have translatable content. If there anyone who knows this or is there any documentation around describing which elements must be translated?

I also saw some proposals regarding the internationalization of RDL files. It seems that the proposed solutions were designed for developers and not for professional translators. In an environment where you have to translate several hundreds of RDL files into let€™s say 20 languages you can€™t expect that translators start to code RDL files. Are there any other approaches that can be used for a more efficient translation of RDL files?

Any feedback is appreciated.


Achim Herrmann

View 1 Replies View Related

Translate DSTX File

Dec 4, 2007

Is it possible to translate a DTSX/XML file into VB.Net or C# code, like you can do with a WSDL file? If so, is there a SSIS utility or third party available? Thank you.

JGL

View 4 Replies View Related

Translate Equivalent In Sql Sever

Apr 24, 2008



Hi,

I have an alphanumeic string as one of the column values.I want to get numeic value out of the string.
I was planning on translating all the characters of the alphanumeric sting to spaces and then using ltrim and rtrim on it should give me the required numeric sring.But there is no translate function in sql server

Example: abcd123xy 123
xyz45 45

Can someone provide me a way to get the numeric value out of the strng.


Thanks
Bobby

View 7 Replies View Related

Columns Vs. Rows

May 10, 2007

hi,I'm building a multi-lingual website In my database tables I have, in some of them, a column with the Language, because some of the columns depend on what language the user wants to see the site.My question is:  what is better? have that column and consequently two row (for two languages) with repeated column information? or have two column within a row with the language specification?e.g. table: id, description, price(1) With language:id,description, price, language='EX' id,description, price, language='EN' vs.(2)  id, descriptionEN,descriptionEX,price   if I have 500 products in 1 whould result in 1000 entriesin 2 just 500 results can anyone tell me a diference/advantage between the two approachs?thanks in advance.  

View 1 Replies View Related

Rows As Columns

Oct 6, 2005

is it possible to write a query so that we can have all rows of one column in a  single columnTIA

View 1 Replies View Related

Rows Become Columns Help!

Dec 5, 2005

I am building a calendar table for the most reason four weeks activitis and I have had a temp table data in table A (See my attached file) and I want to
make it as the format in table B as final. How to convert it? Please help!

Thank you!

Suin

View 2 Replies View Related

Columns To Rows And A Sum

Nov 19, 2013

I am using SQL 2008. I have a database called ISCmetrics and a table called Meeting, the table meeting has 5 columns id

( int),TEAMNAME (varchar),DATECOMPLETE (varchar),STATUSNAME (varchar),STATUSLEVEL (varchar)

We have around 20 different team names , and every team enters data into the database every day, and we have around 7 Different STATUSNAME they are always the same , the STATUSLEVEL is always a 1 or a 0 , so TEAMA enters a value every day for each of the 7 STATUSNAME, and the value is either a 1 or a 0 .

The output for a Select * from ISCMetricslooks like this

id TEAMNAME DATECOMPLETE STATUSNAME STATUSLEVEL
1 TeamA 20131022 STATCONTACT 1
2 TeamA 20131022 STATACTION 1
3 TeamA 20131022 STATABC 1

4 TeamB 20131022 STATCONTACT 1
5 TeamB 20131022 STATCTION 0
6 TeamB 20131022 STATABC 1

7 TeamA 20131021 STATCONTACT 0
8 TeamA 20131021 STATACTION 1
9 TeamA 20131021 STATABC 0

10 TeamB 20131021 STATCONTACT 1
11 TeamB 20131021 STATACTION 1
12 TeamB 20131021 STATABC 1

What i am trying to achieve is this, i want the teams in one column then a column for each of the dates , and then sum of the STATUSLEVEL in each row as shown below for the day and team .....

TEAMNAME 20131022 20131021
TeamA 3 1
TeamB 2 3

View 20 Replies View Related

Rows Become Columns

Jan 18, 2007

hello all,
i am trying to create a view from a table that will keep track of the time between each stage of tasks given. take a look at the data below:


progressID taskIDstage status theDate
------------------------------------------------------------------------
1407525 1091657In Progress Logged 2006-11-16 10:00:24.000
1407526 1091657 In Progress Inprogress 2006-11-16 12:08:59.036
1407214 1091657In Progress Resolved 2006-11-16 14:15:48.000
1407220 1091657Closed Solved 2006-11-16 14:36:05.000


i would like to be able to have just one row per task ID showing the difference between the stages, as shown below . only the 2nd column is a date, the rest are are hours (datediff) between the stage and its preceeding stage :

taskID Logged InProgress Resolved Solved
1091657 2006-11-16 10:00:24.000 2.08 2.07 0.21


is it possible to achieve such a transformation using views and a number of select statements (i.e no dts)? all assistance will be highly appreciated.

regards,

ptah

View 2 Replies View Related

Rows To Columns

Jun 9, 2007

Afternoon

I am trying to write a query that will return the columns: year/ month, each status type (unknown how many types there are)

Each row is a different join year/ month

Each cell has the count of users that joined in that rows year/ month and currently have the status of the column.

At the moment I have the following query:

SELECT [remortgage-status].status, COUNT(1) AS CountTotal, YEAR([remortgage-log].datetime) AS Year, MONTH([remortgage-log].datetime) AS month FROM [remortgage-status] INNER JOIN [remortgage-log] ON [remortgage-status].clientid = [remortgage-log].clientid WHERE ([remortgage-log].action = N'Joined') GROUP BY [remortgage-status].status, YEAR([remortgage-log].datetime), MONTH([remortgage-log].datetime)

The problem is that each different status is a new row rather than each status being a column.

What do I need to do to correct this? - I dont know all the different possible statuses at this point

View 9 Replies View Related

Columns Into Rows

Feb 29, 2008

Hi,
I've a table called months with one column month. The result set will be
month
=====
Jan
Feb
Mar
...

Now i want to convert those values as rows. Means,

Jan Feb Mar
===========

Suggest me a solution for the above problem.


Thanks
Somu

View 2 Replies View Related

Rows As Columns

Jul 20, 2005

I know this is a self join, but I can't remember exactly how it goes.Could someone help me out?create table A{int idA,varchar(30) dataA}create table B{int idB,varchar(30) dataB}create table A_B{int idA references A(idA),int idB references B(idB)}insert into A values(1, "foobar")insert into A values(2, "barfoo")insert into B values(1, "a")insert into B values(2, "b")insert into B values(3, "c")insert into B values(4, "d")insert into B values(5, "e")insert into B values(6, "f")insert into B values(7, "g")insert into B values(8, "h")insert into A_B values (1, 1)insert into A_B values (1, 2)insert into A_B values (1, 3)insert into A_B values (1, 4)desired resultsfoobar a b c dThanks,-- Rick

View 9 Replies View Related

Columns To Rows

May 26, 2006

Lets say I have the following rows..

ID,Net,Gross,Total
1 ,25.00,55.00,100.00
2,35.00,65.00,250.00

What would be the best way to do this...

ID, Description, Value
1, Net, 25.00
1, Gross,55.00
1, Total, 100,00
2, Net 35,00

I was using the multicast and doing a bunch of derived columns but it seems like there should be a eaiser way to do this.

Any help would be appreciated, thanks.

Mardo

View 1 Replies View Related

Rows As Columns

Mar 24, 2008

Hi


i have rows as follows


1 col1 value1

1 col2 value2

1 col3 value3

2 col1 value4

2 col2 value5

2 col3 value6


need result as

id col1 col2 col3

1 value1 value2 value3

2 value4 value5 value6


How to achieve this?


I am trying to achieve this using Pivot, but it is aggregating.

View 8 Replies View Related

XML Columns To Rows

Mar 14, 2007

I have a large amount of data in an XML file. The file is very simple. Off of the root node are category nodes and each category node has many detail nodes. The detail node consist of the node name and the node value. Rather than map the detail to matching named fields in a single record, I would like to send the detail node data to individual data records where the category code, node name and node value are the only fields in the record. For example,

Starting with

<Category>

<Code>001</Code

<Details>

<DetailCode123>75.87</DetailCode123>

<DetailCode728>12.98</DetailCode728>

<DetailCode387>55.72</DetailCode387>

</Details>

</Category>

I want to be able to pick up the 001 code for the category and then transform the above data into 3 separate table records with the following fields (CatCode, DetailCodeName, DetailValue).

001, DetailCode123, 75.84

001, DetailCode728, 12.98

001, DetailCode387, 5572

Does this sort of transform exist? If not, I will have generate my own parsing script. Thought it was worth asking before doing the additional work.

Thanks

View 2 Replies View Related

Rows Into Columns

Aug 28, 2006

I am converting rows into columns :

Schedule_S1 contains more than 1 rows with different FROM_DATE and TO_DATE

The query should merge 2 rows into 1 row with 2 different FROM_DATE AND TO_DATE

The following query works fine when there are more than 1 records. When there is only 1 record, it should still return the record (with FROM_DATE_2 and TO_DATE_2 as nulls). Thanks for any help.

SELECT
ml1.P_ID,
ml1.S_ID,
ml1.CURRENT_DAY,
ml1.FROM_DATE AS "FROM_DATE_1",
ml1.TO_DATE AS "TO_DATE_1",
ml2.FROM_DATE AS "FROM_DATE_2",
ml2.TO_DATE AS "TO_DATE_2"
FROM
Schedule_S1 ml1 JOIN
Schedule_S1 ml2 ON
ml2.FROM_DATE > ml1.FROM_DATE
WHERE
ml1.P_ID = 59014 AND
ml1.S_ID = 25691 AND
ml1.CURRENT_DAY = 3 AND
ml2.P_ID = 59014 AND
ml2.S_ID = 25691 AND
ml2.CURRENT_DAY = 3
ORDER BY
ml1.FROM_DATE

View 9 Replies View Related

Rows And Columns

Jan 3, 2007

I have a query that reports all of the data I want. However it creates about 40 columns and 10 rows. I would like to swap the display so that it shows 10 columns and 40 rows, which would cause it to print out more readable. Can it be done?

View 4 Replies View Related

Columns From Rows

Mar 23, 2006

Hello,



I trying to make columns from rows? How do I do that? I am using SQL Server 2000.



I thank in advance anyone capable of helping me.



E. Woods

View 3 Replies View Related

Rows Into Columns And Columns Into Rows

Aug 14, 2007

I have data in a table. I want the values in the rows to place in columns and columns into rows.
Eg:-A table. It consists of three columns and three rows.

name id dept
a 1 x
b 2 y
c 3 z

I want the resultant table should look like this

a b c
1 2 3
x y z

Whether it's possible ?

View 1 Replies View Related

Analysis :: Translate Named Sets

May 19, 2011

I have some Named Sets that I want to translate. I have done exactly the same way as with the Calculated Members but the Sets don´t use the translations? Any ide why?

View 2 Replies View Related







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