Rename column name from another table with junction - sql

I have a question about SQL. I want to rename my column when I extract them to Excel with ODBC. My column name are encoded but there is a table that allow me to translate them. Is it possible to display my request with modified column name in order to read them more easily.
Table A
MMCONO
MMSTAT
MMITNO
300
20
110599V0
300
20
058867CAP9
Table B
Code
Label
MMCONO
Company code
MMSTAT
Item status
MMITNO
Item number
Expected display for the extract
Company code
Item status
Item number
300
20
110599V0
300
20
058867CAP9
Can you help me please ?
Thanks in advance :)
I think that a junction could help me or a lookingV in Excel but it would be better if it's native SQL.

Related

Extracting data from SAS data set based on values with different length

I am looking to automate a process which has a sales dataset and a specific column named SALES CODE which is of 5 letters.
Based on the input given by the user I would like to filter the data but the problem is the user can give multiple sales codes and sometimes the length of codes could be 5,4,3,2 or 1 based on the condition. How will I filter out the required rows based on the above condition?
SALESCODE area value units rep
A10AA KR 100 10 Jay
B10AQ TN 120 12 Jrn
C10AH KR 200 10 Jay
T11TA TR 180 10 Jay
Say if I give the input as A10AA, B10A, T11 I should be able to
Get the sales data with codes A10AA, B10AQ, T11TA. kindly help.
Use the IN operator. Since you want to match values that start with the specified value use the : modifier. Since your values are character values make sure to include quotes.
proc print data=sales_data ;
where salescode in: ("A10AA" "B10A" "T11");
run;
If you want you can use commas between the values in the list, but I find it easier to type spaces instead.

Excel VBA create columns and populate with data based on another column

Okay so I have to create two new columns and populate it with data from another worksheet if the values for another column matches. I'll break it up to make it easier to understand. There are two worksheets namely; "JULY15Release_Dev status" and "JULY '15 Rel".
Both of these worksheets have a header of "eRequest ID" for column A. I need to create two new columns for "JULY15Release_Dev status" and populate it with data from "JULY '15 Rel" if the "eRequest ID" matches for that specific row of data.
By creating two new columns and populating it with data, it doesn't necessarily have to be "creating then populating", copying that exact 2 columns is also fine, so long as the data remain intact. The data will be in date/time format if it affects anything. Thanks in advance for any help as I'm a total beginner at this!
Let's say, before we do VLOOKUP, our JULY15Release_Dev status sheet looks like this:
A B C
1 eRequestID FirstName Lastname
2 10
3 30
JULY '15 Rel looks like this:
A B C D ....
1 eRequestID FirstName Lastname Age
2 10 Jon Smith 40
3 20 Matt Kahn 50
Our task is to get FirstName and Lastname from JULY '15 Rel into JULY15Release_Dev status.
After adding VLOOKUP in JULY15Release_Dev status, the sheet looks like this:
A B C
1 eRequestID FirstName Lastname
2 10 =VLOOKUP(Sheet1!A2,'JULY ''15 Rel'!$A$1:$C$3,2,FALSE) =VLOOKUP(Sheet1!A2,'JULY ''15 Rel'!$A$1:$C$3,3,FALSE)
3 30 =VLOOKUP(Sheet1!A3,'JULY ''15 Rel'!$A$1:$C$3,2,FALSE) =VLOOKUP(Sheet1!A3,'JULY ''15 Rel'!$A$1:$C$3,3,FALSE)
Give it a shot and see how it works for you.
Alternate to answer with diagram
=INDEX(Sheet!A:1:1048576, MATCH(A2, 'JULY ''15 Rel'$A:$A,0),[column number])
no data sort necessary
if you want to put it into a macro it is a bit redundant unless used based on other variables or tasks.

Display only two fields from Access table

New to Access here... I asked a similar question the other day, but have a new twist for a different form I am creating.
Say I have a table (tblNamesAndValues) that looks like this:
Name Value
---- ----
Mary 100
Carrie 500
Terri 999
Gerrie 749
I have created a form that displays all four names and values.
My question is this: how can you make the form display only the names Mary and Terri and their values, and have the values in updateable textboxes? On top of that, is there any way to only display those two, and not the blanks underneath that allow new entries?
Thanks in advance...
You can filter the form or use a query instead of the table as table source:
select * from tblNamesAndValues where name = "Mary" or name = "Terry"
For disabling the blank line, just set the AllowAdditions property of the form to false.

How can I merge rows (of a particular column) having the same value in SQL Server Reports RDL?

I'm new to working with SQL Server 2005 Reporting Servives using RDLs in BIDS.
I need to modify an existing report so that I can merge cells in adjacent rows which would have the same value for that particular column.
Ex: consider this is the table returned from the stored procedure used by the reports RDL.
_________________________________________________
Id SubCategory Field1 Field2 Total
_________________________________________________
1 a Bob US 17
1 b John UK 17
2 a Mary AUS 12
3 d Ram IND 19
4 b Alex UK 09
4 c Abby FR 09
5 e Tim IT 03
_________________________________________________
Table Example - Couldn' Format Text :( Image here : http_://i.stack.imgur.com/gWEH5.png_
What I need to do is I want the cells merged into one where two adjacent rows in the same column have the same value.
Like Id 1 is repeated twice, so the cells for these must be merged. (Also 4)
Similarly for the last column Total for cells with Ids 1 and 4 must be merged.
The RDL has "TextBox" for columns, I saw some other questions in this forum but were related to Tablix or Matrix, so I thought it would be better if I mentioned it.
I need this merging to be done in the RDL, and this should also be present when exported to Excel.
Hoping someone will be able to help soon.
Change the SQL query to use a group by on ID.
in reporting services drag Id On Row group Of Tablix Upaer than Detail Group
and drag other Fields(except Total) Besid ID and befor vertical dash line In the table.
and drag Total to first cell afte vertical dash line

Sort Excel Grouped Rows

I have a spreadsheet that has information in groups. The header row contain company names and information and then the grouped rows beneath them contain names of people in the company.
Company Name | Number of Employees | Revenue |
Employee Name | Email | Phone
Is there anyway to sort by the number of employees and/or revenue and keep the grouped employee information below the company with the information?
Normally when I try it, it will sort the company information but keep the employee information in the order that it is entered.
If I understand your question correctly, I have a way you can accomplish what you want (don't know if there is a more efficient method).
Write code which will, for each company header row, copy the number of employess and revenue data into two of the chosen unused columns. The data needs to be copied into the columns for both the header company row and detail employee rows.
In the third column assign a sequence number. This is to keep data together and in order when sorting by employee/revenue.
Now you can sort by either the newly created number of employees and/or revenue columns (along with the sequence column to maintain ordering within company).
After the sort you can delete the extra copied data rows.
So if your data looked like this to start with...
A B C
Penetrode 200 750000
Micheal Bolton mbolton#pene.com 555-555-3333
Samir N samirn#pene.com
Initech 500 500000
Bill Lumbergh umumyeah#init.com 555-555-1212
Peter Gibbons pgibbons#init.com 555-555-2222
Your code would then copy the employee count and revenue data and sequencify the rows using three unused columns.
A B C D E F
Penetrode 200 750000 200 750000 1
Micheal Bolton mbolton#pene.com 555-555-3333 200 750000 2
Samir N samirn#pene.com 555-555-3334 200 750000 3
Initech 500 500000 500 500000 4
Bill Lumbergh umumyeah#init.com 555-555-1212 500 500000 5
Peter Gibbons pgibbons#init.com 555-555-2222 500 500000 6
Then you can code a sort on any of the column combos: (D,F), (E,F), (D,E,F), or (E,D,F)
Better late than never, I suppose, but I feel my LAselect plugin would have solved your problem. I created this plugin because I do much non-standard 'stuff' with my data and needed a tool to handle it. LAselect can produce your 'group' output too and you would not need hidden columns or anything. I mean, you would not need to change the screens you are used to to sort them in whatever way you wanted.