w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
SQL Script to split single data rows into multiple data rows based on a condition
I'm sure this will not give me many upvotes because of it's complexity, but still this is interesting task. I think it could be done by cursor approach, but it's also possible with recursive CTE. I'll try to make it as readable as possible, precalculating values with outer apply surely helps here. I've modified you schema a bit. I think you have to store Lot Qty in a different table, something like: create table Products ([Product] varchar(12), [Lot Qty] int); insert into Products values ('Addidas Shoe', 25), ('Puma Shoe', 30); You could still store Lot Qty in your Order table, but it's not normalized. As for the question, I think recursive CTE can help you here: with cte1 as ( select row_number() over(partition by c.[Product] order by c.size) as row_num, c.*,

Categories : SQL

Genymotion. How to pull database from device. my /data/data/ folder appears to be empty
I managed to kind off go around the issue so I post my solution in case someone will find it helpful. Previously I've been creating VM's with no google apis, superUser app crashed every time I wanted to root the phone. so I created VM that is provided with google play and downloaded SQL Debugger App. I also use this code in my test suite and so I fetch db to SD-card at the end of every test I run. That way I don't need to have superuser permissions. public static void copyDbToSd(Context context) { File dbFile = context.getDatabasePath((String) DatabaseHandler.DATABASE_NAME); InputStream myInput; try { myInput = new FileInputStream(dbFile); OutputStream myOutput = new FileOutputStream( Environment.getExternalStorageDirectory()

Categories : Android

Store Time series data in SQL Server, and pull the data dynamically
You should add FundId as a foreign Key to FundData, add Begin and End date for each record (assuming I understand the problem correctly) CREATE TABLE [dbo].[FundData]( [Dates] [datetime] NOT NULL, [FundId] int NOT NULL, [Value] [float] NULL, [BeginDate] [datetime], [EndDate] [datetime], CONSTRAINT [PK_FundData] PRIMARY KEY CLUSTERED, CONSTRAINT [FK_FundData_Fund] FOREIGN KEY FundId REFERENCES Fund(FundId) ) you can then do the following where @FundId, @BeginDate and @EndDate are all T-SQL variables or stored procedure parameters SELECT Value FROM FundData WHERE FundID = @FundId AND BeginDate >= @BeginDate AND EndDate <= @EndDate

Categories : Sql Server

How to pull data from a SQL Query based on data/id relationship. Using ASP.net WebMatrix
Instead of: @{ DataRow[] foundRows; foundRows = queryformdata.Select("field_name LIKE 'f_name'"); } Try this: @foreach(var queryformdata = db.Query("SELECT * FROM document_data WHERE doc_id = @0", 1534)) { <input type="text" id="@queryformdata.field_name" name="@queryformdata.field_name" value="@queryformdata.field_data" /> }

Categories : C#

Is it possible to pull data from scanned documents and dynamically have the data put into sql server?
You can use basic .NET functionality to get the scanned version of the document (e.g. JPEG, PDF) from user via an upload box, then you must use an OCR to get the content of the document as text and save them in the database. I don't think you can directly USE the scanner, by ASP.NET.

Categories : Asp Net

Split array vertically, add rows of data, sort, and then apply regression for rainfall data
Here's a solution to your questions (1) and (2). Can't help you with the regression without more information about what you have in mind. # Split array based on where the 'nan' values are dataSets = filter(lambda x: len(x) > 0, np.array_split(alldata,np.where(np.isnan(alldata[:,1]))[0])) # Delete the rows with 'nan' in it. dataSets = [np.delete(dataSet, np.where(np.isnan(dataSet)), axis=0) for dataSet in dataSets] startYear = 1966 endYear = 1981 startMonth = 1 endMonth = 12 blank_rainfall_value = np.nan # Insert rows of the form ['nan', year, month, 0] for all relevant years/months except where there is already a row containing that year/month extendedDataSets = [] for dataSet in dataSets: missingMonths = [[dataSet[0][0], year, month, blank_rainfall_value] for year in range(sta

Categories : Python

When editing data in JQuery popup, data of only first row is displayed for all rows
IDs must be unique. See: Does ID have to be unique in the whole page? But there is a better way to do what you are trying to do: 1) include the unique ID in the <tr>, so you end up with something like: <tr id="id123">. Prefix the user ID with at least one alphabetical character, for example "id" or whatever you want. That's because you don't want the HTML ID to be a number (like id="12356"). The ID should start with a character. 2) Add a click or dblclick handler on the table's rows, something like: $(document).on("click", "#example tbody tr", function () { editUser(this.id.substring(2)); } ); Note the substring(2) strips away the preceding "id" text, so you are left with just the actual User ID. 3) Use this value in the editUser function: function edi

Categories : Jquery

Storing data in multiple rows vs serialized data in MySQL
In MySQL, a separate row with separate columns for each value is absolutely, definitely the way to go. That way you can create indexes on these columns, as well as query them by value more easily, even if you didn't have indexes. (You definitely should have indexes on the values you intend to query by.) In PostgreSQL, however, you could store values serialized to JSON (via json_encode,) and index separate values inside them. However, either way, you'd still need to store every friend record in a separate row in the table. It's not like you could just dump a serialized value of a 5000 record array into a database and call it a day.

Categories : PHP

how to integrate properties defined on multiple rows using a data.frame or data.table long format approach
If I understand OP correctly, you want smth like this: dt[, {bigN = .N; .SD[, .N / bigN, by = subg]}, by = group] or maybe (and very similarly) this: dt[, {counts.sum = sum(counts); .SD[, counts / counts.sum, by = subg]}, by = group]

Categories : R

pull data from a file
1 mistake in your factory declaration. There is no method getFruitsAsync (which you trying to use in controller). Declare it inside return {} as property = function. 2 mistake: you don't have field 'fruits' in response, your response is array, so $scope.fruits = results.fruits; should be $scope.fruits = results;

Categories : Javascript

how do you pull XML data from a C# file
This looks very strange: myChart.setXMLUrl("/Controls/TaskOrder/TaskSummary.asc/TaskSummary.ascx.cs"); You are probably wrong. :-) You must connect xml/json data from url. So, create ashx handler to provide XML/json data by some arguments and than put url of this handler to your script. Also take a look, if there would be possibility to give data to FusionChart object from javascript variable. It may help. Here you can see ashx handler sending XML data: C# Change my sitemap from ashx to xml (only data are missing).

Categories : C#

Pull data from a database that has a similar name to "x"
It does not matter if you use = or like if you do not put any wild cards in your query I have added % both sides of your search term so it will now search for items like "blah blah Term blah blah" $query = "SELECT Serial_No, Make, Model, Gauge, Barrel_Length, Price FROM PG_inv WHERE Model like '%" . $make . "%' ORDER BY PG_inv.Price"; LIKE "FOO" is the same as = "FOO"where asLIKE "FOO%" will say anything starting with FOO

Categories : PHP

pull data from json array
options is an array, and price is also an object: "price":{ "formattedAmount":"$40.00", "amount":4000, "currencyCode":"USD" }, This works, though I think you may need to have more iterations to show all the options, if there's more than one: html: v.options[0].price.formattedAmount, http://jsfiddle.net/WNd4r/

Categories : Jquery

Pull data into full calendar using php
Try this if it is what you are looking for. <?php $str = '[ {"id":"53","start":"2013-06-06","title":"Assignment2"}, {"id":"52","start":"2013-06-07","title":"Assignment1"}, {"id":"54","start":"2013-06-08","title":"Assignment3"} ]'; $str = str_replace('{"', '{', $str); $str = str_replace('":', ':', $str); $str = str_replace(',"', ',', $str); echo "<pre>" . $str . "</pre>"; ?>

Categories : PHP

Heroku - how to pull data from one database and put it to another one?
There are ways to do this in straight SQL. If you're comfortable with that, go for it. This way is for devs comfortable in Rails -- so we pull data out using JSON, and create users with a new ID in the new database from that JSON. Since you're pulling only 1 table, AND you want to reset the IDs to the new database, I recommend: bring a copy of the database locally with pbackups File.open('yourfile.json', 'wb') {|file| file << User.all.to_json } Connect to your new database, and move yourfile.json up there then: users_json = JSON.parse(File.read('yourfile.json')) users_json.each do |json| json.delete("id") User.create(json) end

Categories : Ruby On Rails

I am trying to pull some data from a website I host, to another one
Ajax request are subject to CORS (http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) for security reason. You can make it work by configuring proper HTTP Headers on your ..*.50 server.

Categories : Jquery

Javascript pull data from string?
DEMO (look in your debug console) You will want to split the string by the token '&' first to get your key/value pairs: var kvpairs = document.location.hash.substring(1).split('&'); Then, you will want to split each kvpair into a key and a value: for (var i = 0; i < kvpairs.length; i++) { var kvpair = kvpairs[i].split('='); var k = kvpair[0]; var v = kvpair[1]; if (k != 'access_token') continue; console.log(v); //Here's your access token. } Here is a version wrapped into a function that you can use easily: function getParam(hash, key) { var kvpairs = hash.substring(1).split('&'); for (var i = 0; i < kvpairs.length; i++) { var kvpair = kvpairs[i].split('='); var k = kvpair[0]; var v = kvpair[1];

Categories : Javascript

Pull data from RESTful server to SQL
You could use following and I'm considering you will use java as a programming language Create a new database structure (tables). For example in MySQL database. Use jdbc to connect your database. Use Apache HTTP client or Spring RestTemplate library to consume the data from Rest API and insert into your database table

Categories : SQL

SQL Script to pull duplicate data
Oracle uses WM_CONCAT or LIST_AGG to do this anymore I think sysbase uses List() Source documentation describing function So.. using your SQL Select Field1, list(Field2) FROM table Group by Field1 SELECT item_loc.niin, list(item_loc.location_number) FROM item_loc GROUP BY item_loc.niin I just removed a space after list before the ( so List ( became List( Now the nature of the error your getting indicates list isn't a function in your version of sybase... I'm still trying to find documentation on sybase 15.3 and proper syntax for it (or if it supports List)

Categories : SQL

Using String Formatting to pull data from a dictionary
When you do number_stats["chm%"] % (value,), you are doing number_stats["chm%"] first and then applying % (value,) to the result. What you want is to apply the % directly to the string: number_stats["chm%s" % (value,)] Note that you need %s; % by itself is not a valid string substitution. However, there is probably a better way to do it. Why does your dictionary have keys like "chm1" and "chm2" instead of just having the numbers be the keys themselves (i.e., have keys 1 and 2)? Then you could just do number_stats[value]. (Or if you read value from raw_input you'd need number_stats[int(value)]

Categories : Python

Unable to pull data from json using python
json['response']['context'] is a list, so that object requires you to use integer indices. Each item in that list is itself a dictionary again. In this case there is only one such item. To get all "name": "health-state" dictionaries out of that structure you'd need to do a little more processing: [attr['value'] for attr in json['response']['context'][0]['attributes'] if attr['name'] == 'health-state'] would give you a list of of matching values for health-state in the first context. Demo: >>> [attr['value'] for attr in json['response']['context'][0]['attributes'] if attr['name'] == 'health-state'] [u'ok']

Categories : Python

Dynamically Pull Data from Dynamics CRM Online
My suggestion in this situation is always to create a C# Web Service that will act as a bridge between CRM and your php code. The Web Service use .NET so can easily pull the data from CRM, and because is a Web Service you can consume it by any platform (with SOAP or REST is your decision)

Categories : C#

Excel VBA: More efficient way to pull in data from another workbook?
What you can do to avoid errors from multiple simultaneous connections is relying on different files for different users; that is, opening a copy of the target spreadsheet. Here you have a code: Dim xlz, xlz_copy, extension As String Dim count As Integer Dim completed As Boolean xlz = Sheet1.Range("o1").Value & "Region PlanningTestDB" xlz_copy = xlz extension = ".xlsx" xlz = xlz & extension count = 0 Do count = count + 1 If Dir(xlz_copy & count & extension) <> "" Then Else If (count > 1) Then xlz_copy = xlz_copy & count Exit Do End If Loop While (Not completed) xlz_copy = xlz_copy & extension FileCopy xlz, xlz_copy Set xlw = Workbooks.Open(xlz_copy) 'YOUR CODE xlw.Close Kill xlz_copy Bear in mind that Excel reading is

Categories : Excel

WP Plugin Pull out data from db for edit or delete
I have created such plugin without using ajax In the table I've created 2 links - "edit" and "delete", and sent the id of the element <a href="admin.php?page=film_add&act=upd&id=<?php echo $id;?>">Edit</a> <a href="admin.php?page=myplug/muyplg.php&info=del&did=<?php echo $id;?>">Delete</a> if $info=del if($info=="del") { $delid=$_GET["did"]; $wpdb->query("delete from ".$table_name." where id=".$delid); } and similarly for "edit" $act=$_REQUEST["act"]; if($act=="upd") { $recid=$_REQUEST["id"]; $sqlL="select * from ".$table_name = $wpdb->prefix . "member where id=$recid"; $result = mysql_query($sqlL) or die ('Error, query failed'); if (mysql_num_rows($result) > 0 ) { if($row = mysql_fetc

Categories : Wordpress

How to pull Data from Youtube CMS using Google AppScipt
Have you actually done the OAuth flow and stored the access/refresh tokens? If not, take a look at these two YouTube videos for Apps Script integration with the Data and the Analytics API http://www.youtube.com/watch?v=VVhsK5jH6u8 http://www.youtube.com/watch?v=eumC0nIw-lk The code for both those videos are available here - https://github.com/entaq/GoogleAppsScript/tree/master/YouTube https://github.com/entaq/GoogleAppsScript/tree/master/IO2013/YouTubeAnalytics

Categories : Google Apps Script

Express.js - error when trying to pull data from mysql
You are assuming that y (holding all the request rows if of the given language) is at least as long as "all the humans" (resultss), which seems to me to be almost always false. In addition, you are not escaping the req.query.criteria and req.query.val, leaving yourself wide open to SQL injection attacks. You should fix that :) (It would also help others if you posted the actual error message you are getting. And if you actually showed us a few human rows).

Categories : Javascript

I need to pull from two tables into a loop and match the data
If you are using two tables in your query, there should be a column in the second table linking the row to a row in the first column Once you identified this field, write your query like this : $sql="SELECT * FROM $tbl_name, documents_main WHERE show_listing='1' and user_type='1' and $tbl_name.FIELD_TO_BE_DEFINED = documents_main.ANOTHER_FIELD_TO_BE_DEFINED"; Or : $sql="SELECT * FROM $tbl_name inner join documents_main on $tbl_name.FIELD_TO_BE_DEFINED = documents_main.ANOTHER_FIELD_TO_BE_DEFINED WHERE show_listing='1' and user_type='1'";

Categories : PHP

VBA: Pull data from website using objElement and objCollection
I've moved on from this question, as I have now pinpointed the real issue. This is my updated issue: VBA: Pull data from a form within one of many frames on a website

Categories : Excel

Using Javascript to pull data from an RSS Atom feed
Two things to check for starters: 1) Your NewsFeed.aspx needs to be hosted at exactly the same protocol, sub-domain, domain, and port as the page calling it. Otherwise browser security kicks in and prevents you from using an XHR. If you're trying to read a 3rd party RSS feed you may need to use a proxy. 2) The content-type header of the response needs to be text/xml. There are ways to get around this, but it's better if the content-type is accurate.

Categories : Javascript

Turning a Data.Frame with 28441 Rows in it to a Dataframe with 28 Rows and 1000 Columns in R
Not sure what language this is coded in but I think I understand your problem. If your original is all in the first column of zip.codes(I assume this is the old dataframe), you want [i,1] meaning row i, first column. Your j should go from 1 to for (i in 1:length(zip.codes)) { k = i % 1000 for(j in 1:1000) { new.zip.codes[k,j]<-zip.codes[i,1] } } Using the % as a modulo operator, you can pick out the row number you want, had have j as your column control. This is extremely useful when you know your fixed table size. Hope this helps.

Categories : R

Mysql query to pull data in the form of matrix
You will need to join on your table twice to get the group and places, then you can use an aggregate function with a CASE expression to convert the rows into columns: select g.subtopic as `group`, sum(case when p.subtopic = 'Paris' then 1 else 0 end) Paris, sum(case when p.subtopic = 'US' then 1 else 0 end) US, sum(case when p.subtopic = 'Venus' then 1 else 0 end) Venus from table2 g left join table2 p on g.id = p.id and p.topic = 'place' where g.topic = 'group' group by g.subtopic; See SQL Fiddle with Demo. If you are going to have unknown values for the subtopic, then you can use a prepared statement and dynamic SQL: SET @sql = NULL; SELECT GROUP_CONCAT(DISTINCT CONCAT( 'sum(case when p.subtopic = ''', subtopic, ''' then 1 else 0 end) as `',

Categories : Mysql

jquery pull data from html attribute on click
use this (don't use duplicate id's though) $(document).ready(function() { $(":input[id='alarm']").click(function() { alert($(this).attr("url")); }); });

Categories : Jquery

MySql query to pull data from multiple tables
This is untested, but should do the trick: SELECT a.`year`, COALESCE(b_stock.rec_count, 0) as `stock`, COALESCE(b_water.rec_count, 0) as `water` FROM table1 a LEFT JOIN ( SELECT b2.`year`, COUNT(b.*) as rec_count FROM table2 b JOIN table1 b2 ON b2.id = b.id WHERE b.topic = 'stock' GROUP BY b2.year ) b_stock ON b_stock.`year` = a.`year` LEFT JOIN ( SELECT b2.`year`, COUNT(b.*) as rec_count FROM table2 b JOIN table1 b2 ON b2.id = b.id WHERE b.topic = 'water' GROUP BY b2.year ) b_water ON b_water.`year` = a.`year` GROUP BY a.`year` ORDER BY a.`year`

Categories : Mysql

Have trouble figuring out the command to pull data from several tables
You might be looking for JOINS in sql. There are plenty of joins tutorials available. Keep studying. MySQL supports inner, left, right and cross joins.

Categories : Mysql

How to pull the data from Oracle on quarterly based on EFF_Date
I'm not sure what you want to query, so here's an example that will hopefully get you started; it counts rows by quarter based on eff_date: SELECT TO_CHAR(eff_date, 'YYYYQ'), COUNT(*) FROM my_table GROUP BY TO_CHAR(eff_date, 'YYYYQ') The query relies on the TO_CHAR date format code Q, which returns the calendar quarter (Jan-Mar = quarter 1, Apr-Jun = quarter 2, etc.). Finally, be warned that the WHERE clause is not optimizable. If you have millions of rows you'll want a different approach.

Categories : Oracle

pull data from website using VBA excel multiple classname
Your first option is usually preferable since it is much faster than the second method, it sends a request directly to the web server and returns the response. This is much more efficient than automating Internet Explorer (the second option); automating IE is very slow, since you are effectively just browsing the site - it will inevitably result in more downloads as it must load all the resources in the page - images, scripts, css files etc. It will also run any Javascript on the page - all of this is usually not useful and you have to wait for it to finish before parsing the page. This however is a bit of a double edged sword - whilst much slower, if you are not familiar with html requests, automating Internet Explorer is substantially easier than the first method, especially when eleme

Categories : Excel

Where does Add/Remove programs pull data for the "Installed On" column
After a lot of messing around I determined that the Windows Add/Remove programs gets the "Installed On" date from at least three potential locations: For MSI installed applications it gets the date from WIN32_Product (By far the most common way) For non-MSI applications it looks in for the InstallDate value in the corresponding registry Uninstall Key (Example: HKLMSOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstallGoogle Chrome) For non-MSI applications that do not have the InstallDate, Windows looks to see the last date that the Uninstall key was written to and uses that date for "Installed On". It was this last method that had me stumped for so long. This means that any time a non-MSI program that is missing the InstallDate value is updated, and the version number in the Unin

Categories : Windows

How do I set decimal places when I pull data from Bloomberg using Matlab?
Use the format command to set the display to the desired number of significant digits: http://www.mathworks.co.uk/help/matlab/ref/format.html

Categories : Excel

How do I ask DB2 to return to me 1000 rows of data at a time out of 1million rows
The best way to do this would be to use the ROW_NUMBER OLAP Function, which would assign a number (in this case ordered by GEO_DATE), which you could then use to filter with the WHERE clause: SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY GEO_DATE) AS rn A.* FROM your_table A ) --WHERE rn BETWEEN 1 AND 1000 WHERE rn BETWEEN 1001 AND 2000

Categories : SQL

pull last 5 minutes of syslog data (750mb) with tac combo sed/awk/grep/?
e="" for (( i = 5; i >= 0; i-- )) do if [[ -z $e ]] then e=`date +\%R -d "-$i min"` else e=$e'|'`date +\%R -d "-$i min"` fi done re=' ('$e'):' tac /var/log/syslog.log | sed -n -e "/$re/p" -e "/$re/!q" This creates a single regular expression listing all the times from the last 5 minutes, connected with |. It prints the lines that matches them. Then it uses the ! modifier to quit on the first line that doesn't match the RE.

Categories : Bash



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.