SQL server: replace values ​​in the table with the values ​​of another table where both tables do not have the same number of rows

I have two tables at this time.

Table 1
+ ----- + ---- +
id val
1 a
2 b
3 c
4 d
5 e
+ ----- + ---- +
Table 2
+ ---- + ----- +
id val
1 aa
2 bb
3 cc
+ ---- + ----- +

I want a resulting table to look like this replacing the values ​​in table 1 of table 2 as well and keeping the name change intact

Resulting table
+ ----- + ----- +
id val
1 aa
2 bb
3 cc
4 d
5 e
+ ----- + ----- +

I have tried the following code

SET Table1.val = Table2.val
where Table1.id = Table2.id

but I get an error that

table2.id can not be linked

Is there any other solution? Note that both tables do not have the same length.

php – How to join rows / columns of a table in Laravel with domPDF?

I'm working with laravel, and I need to make a report for an inventory control … until now I have achieved this result … enter the description of the image here

I want to add that the data in the column description is a column that was expanded (That is another one of the same type) for example we see that I have 2 phones that become one and that if another phone appears, it is also attached and than in the amount of being possible as a total that in this case should be 2.

In my view I have the following code.

            @foreach ($ inventories as $ inventory)




{{$ inventory-> id}} {{$ inventory-> article-> dsc}} {{$ inventory-> amount}}

{{$ inventory-> code}}

{{$ inventory-> group-> code}}

{{$ inventory-> independent}}

{{$ inventory-> serial}} {{$ inventory-> model}} {{$ inventory-> brand-> name}} {{$ inventory-> color-> name}} {{$ inventory-> incorp}} Bs {{$ inventory-> desincorp}} Bs {{$ inventory-> observation}}

My driver

get ();
            $ pdf = PDF :: loadView ('documents.pdf', compact ('inventories'))
            -> setPaper ('letter', 'portrait');
            return $ pdf-> stream ();

        public function download ()
            $ inventories = Inventory :: orderBy ('articulo_id', 'ASC') -> get ();
            $ pdf = PDF :: loadView ('documents.pdf', compact ('inventories'))
            -> setPaper ('letter', 'portrait');
            return $ pdf-> download ();

Google Sheets Row division in multiple rows

I'm doing a spreadsheet for an event and I need to divide a row into several rows. It's getting data from a form.

I need a script that can organize the data like in the blue rectangle.

enter the description of the image here

How to obtain multiple rows of that subquries

This is my query:

FROM the messages
WHERE m.threadId = mtu.threadId
FROM messages_thread_user mtu
WHERE mtu.userId = 1;

I want to get everything Rows of the subqueries AHow can it be possible? It works fine if I choose only 1 Rows. Or is there another way to write this query?

Conversion of rows to columns in the PowerBi report in the SharePoint Online list

Funny question

You can use an energy query function called "Extract values" to do this.

In my example, I changed the name of the Title column in each list to Project_ID and Tasks_Title. When these are incorporated into Power BI, they are displayed with the name of the original title and must be renamed.


  1. In your Project Task list, update the project ID search to also show the project title.
    enter the description of the image here
    enter the description of the image here

  2. In a new Power BI project, click Get data and choose your SharePoint
    Project_Tasks lists. (The list of projects is not necessary.)

  3. Click Edit, not Load. You are now in Power Query.

  4. Delete the columns without writing. (Many of them!) Now you should see the identification
    (Optional). Title (or Tasks_Title) and project ID

  5. If you changed the name of the Title column in SharePoint, change the title name
    column here for Tasks_Title.

  6. Click on the Group By button on the Start or Transform ribbon.

  7. Click on the double header arrow at the top of the Project_ID column,
    deselect all columns and select Project_Title and Title (or Title
    Project ID). Uncheck "User's original column name as prefix" and click

  8. If you changed the name of the Title column in SharePoint, change the title name
    column here for Project_ID.

  9. Click on the Group By button on the Start or Transform ribbon.

  10. Click on Advanced.

  11. Select Project_ID from the drop-down list.

  12. Click Add grouping and select Project_Title from the drop-down menu.

  13. Click on the Operation drop-down menu and select Add rows.

  14. Change the "New column name" to TaskInfo.

  15. Click on OK

  16. In the Add column ribbon, click Custom Column.

  17. Enter this formula: = Table.Column ([TaskInfo], "Tasks_Title") (This is the "magic" part 1)

  18. Change the name of the column to "Tasks".

  19. Click on OK

  20. Click on the double header arrow at the top of the TaskInfo column and
    click on "Extract values ​​…". (This is the "magic" part 2).

  21. Select a delimiter from the drop-down list, or a custom value such as ",
    "Click on OK.

  22. Now you can delete the TaskInfo column.

  23. Click Close and apply and continue with your report.

The result

enter the description of the image here

My "M" code from the Power Query Advanced Editor (Your URL and GUIDs will be different)

Source = SharePoint.Tables ("https://yourDomain.sharepoint.com", [ApiVersion = 15])
# "0019cad5-ca73-4195-808d-c94a82671472" = Source {[Id="0019cad5-ca73-4195-808d-c94a82671472"]}[Items],
# "Renamed columns" = Table.RenameColumns (# "0019cad5-ca73-4195-808d-c94a82671472", {{"ID", "ID.1"}}),
# "Columns removed" = Table.RemoveColumns (# "Renamed Columns", "{" FileSystemObjectType "," ServerRedirectedEmbedUri "," ServerRedirectedEmbedUrl "," ContentTypeId "," ComplianceAssetId "," Project_IDIrl "" "," Created "," AuthorId " , "EditorId", "OData__UIVersionString", "Attachments", "GUID", "FirstUniqueAncestorSecurableObject", "RoleAssignments", "AttachmentFiles", "ContentType", "GetDlpPolicyTssipments", "" "" FieldValuesAsText "," FieldValuesForEdit "," File "," Folder "," LikedByInformation "," ParentList "," Properties "," Versions "," Author "," Editor "}),
# "Renamed columns1" = Table.RenameColumns (# "Columns deleted", {{"Title", "Tasks_Title"}}),
# "Project_ID expanded" = Table.ExpandRecordColumn (# "Columns1 renamed", "Project_ID", {"Title", "Project_Title"}, {"Title", "Project_Title"}),
# "Renamed columns2" = Table.RenameColumns (# "Project_ID expanded", {{"Title", "Project_ID"}}),
# "Grouped rows" = Table.Group (# "Columns2 renamed", {"Project_ID", "Project_Title"}, {{"TaskInfo", every _, type table}}),
# "Custom Aggregate" = Table.AddColumn (# "Grouped Rows", "Tasks", each Table.Column ([TaskInfo], "Tasks_Title")),
# "Extracted values" = Table.TransformColumns (# "Added Custom", {"Tasks", each Text.Combine (List.Transform (_, Text.From), ","), enter text})
# "Extracted values"

I found a YouTube video that shows an example that is a bit more complex than your needs, but shows how it is done.

Query to collect the single rows of recent TimeSampled using internal joins for multiple servers in MS SQL

Dear ones,
I have written below the internal union query to get the data from my database tables. But the output of this data comes with almost 3k lines. The output is below. I just need data in recent and unique "TimeSampled" rows

enter the description of the image here

select DISTINCT DisplayName, ObjectName, CounterName, InstanceName, SampleValue, max (TimeSampled) as TimeSampled
of PerformanceDataAllView pdv with (NOLOCK)
internal combination PerformanceCounterView pcv in pdv.performancesourceinternalid = pcv.performancesourceinternalid
internal union BaseManagedEntity bme in pcv.ManagedEntityId = bme.BaseManagedEntityId
where ObjectName = & # 39; Processor & # 39; AND TimeSampled> = DATEADD (MINUTE, -5, GETDATE ())
And DisplayName as & # 39;% & # 39;
group by  [PATH], [DisplayName], [ObjectName], [CounterName], [InstanceName], [SampleValue]

How can I retrieve results only with the last rows of Time Sampled with respect to DisplayName. I have almost 5k servers (DisplayName) like this to recover the data.

Request to need help to achieve it.

How do you select a large number of rows in the Google Sheets without having to scroll down after selecting the first row?

In a spreadsheet of 40,000 rows, I want to select the first 2,500 rows to copy them to another sheet. The only way I've seen is
Select the first row and tediously move the
"point" down to include all 2,500 rows. On a computer, this would be a breeze with the
Shift key. How to achieve something similar in the Android sheets? The keyboard does not open unless you are editing a cell, so any keyboard-based solution seems to have no start. Thank you.

excel vba – Merge rows with duplicates and then delete the row

I have created an Excel file that creates a furniture order list. The list can have from 100 rows up to 3000 rows in length, depending on the size of the order.

My problem is that the data that creates the order list includes many duplicates as shown in the image.

What you would need help with is to create a macro that takes all the matching identification numbers and combines it into a row where the quantity is combined. The list price will be the same and the total price is a function taken from the quantity * list price.

View post on imgur.com

I am aware that there are several messages related to problems like mine, but I have not been able to find a solution. I do not have much experience with coding, so I would appreciate all the help I can get!

Save the Google sheet as PDF recently began to show hidden rows

I have a script to save an individual Google sheet as a pdf document inside a certain folder.

Since the content of the sheet is dynamic and sometimes has a load of empty grid rows at the bottom, I have included a method to hide rows without content before exporting the file.

This has worked as required until very recently. Now the function hides the rows but the created file shows the rows as not hidden.

Any idea if this is due to a recent change to the Google Sheets API and is there anything I can do to get back to the previous functionality?

Here is my block of code that previously worked:

// API function to save a single sheet without hiding sheets
// ********************************************** *******************************

function singleSheetAPIExport () {

// Get the URL of the active spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var sheetName = & # 39; Example & # 39 ;;
var main = ss.getSheetByName (sheetName)
var folderID = & # 39; 1wsxxxxxxblah blah & # 39; // Google Drive folder ID

Logger.log (& # 39; maxrows: & # 39; + main.getMaxRows ());
Logger.log (& # 39; last row: & # 39; + main.getLastRow ());

// Base URL
var url = "https://docs.google.com/spreadsheets/d/SS_ID/export?".replace("SS_ID", ss.getId ());

/ * Specify PDF export parameters
From: https://code.google.com/p/google-apps-script-issues/issues/detail?id=3579
* /

var url_ext = & # 39; exportFormat = pdf & format = pdf & # 39; // export as pdf / csv / xls / xlsx
+ & # 39; & size = letter & # 39; // legal paper size / letter / A4
+ & # 39; & portrait = true & # 39; // orientation, false for the landscape
+ & # 39; & fitw = true & source = labnol & # 39; // fit the width of the page, false for the actual size
+ & # 39; & sheetnames = false & printtitle = false & # 39; // hides optional headers and footers
+ & # 39; & pagenumbers = false & gridlines = false & # 39; // hide page numbers and grids
+ & # 39; & fzr = false & # 39; & fzr = false & # 39; // do not repeat row headers (frozen rows) on each page
+ & # 39; & gid = & # 39 ;; // the identification of the sheet

var token = ScriptApp.getOAuthToken ();

// Hide all empty rows in the print sheet
var maxRows = main.getMaxRows ();
var lastRow = main.getLastRow ();
yes (maxRows-lastRow! = 0) {
main.hideRows (lastRow + 1, maxRows-lastRow);

// Get the answer for your specific sheet that can later be blobbed
var response = UrlFetchApp.fetch (url + url_ext + main.getSheetId (), {
headers: {
& # 39; Authorization & # 39 ;: & # 39; Carrier & # 39; + file

// Save the pdf version
var saveFolder = & # 39; PDF & # 39 ;;
var parentFolder = DriveApp.getFolderById (folderID);
var folder, folders = DriveApp.getFoldersByName (saveFolder);
yes (folders.hasNext ()) {
folder = folders.next ();
} else {
folder = parentFolder.createFolder (saveFolder);
name var = main.getRange ("B8"). getValue ();
var cleanName = name.replace (/ ([^a-zA-Z0-9() #%~-]) / g, "-");
folder.createFile (response.getBlob (). setName (cleanName));

// hide the rows again
var fullSheetRange = main.getRange (1,1, main.getMaxRows (), main.getMaxColumns ());
main.unhideRow (fullSheetRange);


How to extract rows from a data frame using a vector with the values ​​of one of the variables in R?

I have a data frame in R and I want to extract from it the rows that have a certain value in one of its variables from the values ​​of another vector.

For example, extract from the dataframe iris the rows with the Species that are in another vector criterion <- c ("mushrooms", "virginica")