Posts

Showing posts from March, 2010

java - Refactoring import statements using Shade relocations in Maven -

i've been using shade relocate dependency com.package.x com.package.y ; when build maven, complains due incompatible types - have change import statements inside code match com.package.y . is way go this? changing imports making intellij complain , breaks ide integration. there no way shade can modify imports? the main use case of shade plugin generate uber-jar while relocating packages inside of prevent conflicts. rule don't want developing against uberjar. if want develop against shaded jar (or you're solely using shade relocate existing jar), you'll need list shaded jar in lieu of original jar, imagine may need clean cyclic dependency.

Insert record into database using javascript, mysql, and php -

i have following js function, makes ajax request, not doing reason. checked alerting url , displays supposed be, variables declared. var request = new xmlhttprequest(); var url = "ajax_js/q_ajax.php?q="+ques+ "&ans="+ans+ "&a="+inp[0].value+ "&b="+inp[2].value+ "&c="+inp[4].value+ "&d="+inp[6].value+ "&cor="+checked+ "&def="+input+ "&q_n="+q_name+ "&c_id="+c_id; request.onreadystatechange=function (){ if(request.readystate==4 && request.status==200){ alert(request.responsetext); } request.open("get", url, true); request.send(); } here code php file. <...

c# - Access form label from another class/namespace -

i know has been asked thousands of time still after lot of research can't find solution , sorry post. i want access label class in namespace. sample of code understand better trying do: public partial class main : form { public main() { initializecomponent(); } } //class in namespace class servers { public void _setlabeltext() { main.label1.text = "new text"; } } how supposed proper way? one option store reference form in constructor this: public class servers { private form _frmmain; public servers(form frmmain) { _frmmain = frmmain; } public void setlabeltext() { _frmmain.label1.text = "new text"; } } and use this: public partial class main : form { public main() { initializecomponent(); var servers = new servers(this); servers.setlabeltext(); } } however, it's t...

wpf - DataGrid.RowStyle only works on initial binding -

i have datatrigger applying style visibility property of datagrid row. datatrigger working fine on initial binding of datagrid (ie - sets row visibility collapsed if filteredout true). i have combobox sets filteredout property true or false each item in observablecollection allpartmalfunctions depending upon user has selected in combobox. here problem: after selecting item in combobox , setting filteredout property each item, the datagrid rows not refresh visible or collapsed , on ui looks same did before selecting in combobox. missing? here xaml: <datagrid itemssource="{binding allpartmalfunctions}" autogeneratecolumns="false" width="auto"> <datagrid.rowstyle> <style targettype="datagridrow"> <style.triggers> <datatrigger binding="{binding filteredout, mode=twoway}" value="true"> <setter property="visib...

amazon s3 - Logistic Regression with SparkR using s3 data -

hi i'm trying replicate more examples sparkr when tried use data in s3 got errors. here code i'm running in rstudio within emr cluster: rm(list=c(ls())) library(sparkr) # initialize spark context sc <- sparkr.init(master="yarn-client", sparkenvir=list(spark.executor.memory="5g"),'logistic') d <- 8 readpartition <- function(part){ part = as.vector(part, mode = "character") part = strsplit(part, "\t", fixed = t) list(matrix(as.numeric(unlist(part)), ncol = 9)) } # read data points , convert each partition matrix points <- cache(lapplypartition(textfile(sc, 's3://mybucket/data.txt'), readpartition)) # initialize w random value w <- runif(n=d, min = -1, max = 1) cat("initial w: ", w, "\n") # compute logistic regression gradient matrix of data points gradient <- function(partition) { partition = partition[[1]] y <- partition[, 1] # point labels (first column of...

tcl - Wrapping program with TclApp causes smtp package to stop working properly? -

Image
so i'm getting strange issue when trying send email company's local mail server using tcl. problem i've written code works, doesn't work wrap tclapp. believe i've included necessary packages. code: package require smtp; package require mime; package require tls; set body "hello world, sending email! hear me roar."; #mime info set token [mime::initialize -canonical text/plain -string $body]; #mail options set opts {}; #mail server + port lappend opts -servers "my_server"; lappend opts -ports 25; tls::init -tls1 1; lappend opts -username "someemail@example.com"; lappend opts -password "somepasswordexample"; #subject + + lappend opts -header [list "subject" "this test e-mail, beware!!"]; lappend opts -header [list "from" "thefromemail@example.com"]; lappend opts -header [list "to" "thetoemail@yahoo.com"]; if {[catch { smtp::sendmessage $token \ {...

python - Appending modified object to list in for loop -- only last modification is stored -

i created function goes through loop, creates variables, , appends them in list. def function(self,record): temp_list_records=[] #depends number of x, got 10, 100,1000,10000 loops loops=int(math.pow(10,x_range)) digits="%0"+str(x_range)+"d" #then create records , add mysql data query x in range (0,loops): end_of_number=digits%x record.dn=dn_number+str(end_of_number) record.gn=gn_number+str(end_of_number) temp_list_records.append(record) return temp_list_records explanation: pass object called record has 2 properties, dn , gn . these properties have structure: 0000213123xx, xx two-digit number. need generate values xx in range between 00 , 99, properties be: 000021312300, 000021312301,... every time append list record , record dn , gn change in range. explain later, during loop, numbers found, once loop finished, objects in list become last 1 ...

r - RAdwords error ("server certificate verification failed") -

when run following code involving radwords package, error seems related certificates. there simple solution this? library(radwords) google_auth <- doauth() error in function (type, msg, aserror = true) : server certificate verification failed. cafile: /home/pavel/r/x86_64-pc-linux-gnu-library/3.2/rcurl/curlssl/ca-bundle.crt crlfile: none the error occurs on ubuntu 14.04, r 3.2.0, rcurl 1.95-4.5, , radwords 0.1.4. i had same issue on ubuntu 14.04, manually downloading (and overriding rcurl shipped version of) cacert.pem curl homepage resolved issue. know it's ugly workaround :)

jQuery ui-sortable open original place holder on drag outside of list -

i have sortable vertical single column list. need: 1) open original placeholder element on start when user drags element outside of list. need prevent drop outside of list. possible? 2) possible add or change tolerance option? need setup reordering (for vertical list) when top border of dragging element overlaps bottom border of list elements. managed while dragginf upward when dragginf down sorting work on mouse overlap. $('#sortable').sortable({ sort: function (event, ui) { var list = $(this), w = ui.helper.outerwidth(), h = ui.helper.outerheight(); list.children().each(function () { if ($(this).hasclass('ui-sortable-helper') || $(this).hasclass('ui-sortable-placeholder')) { return true; } var currelementheight = $(this).outerheight(), overlap = $(this).position().top + currelementheight - ui.position.top, placebefore = ui...

jquery - Lazyloading picture elements -

i'm looking recommendations on how best lazyload picture elements. may use small jquery helper function determine whether picture "on screen". lazy fetching of srcset, i'm not sure right how that. so, ideas? here's example of picture elements working with. thanks! <picture alt="random celebrities" data-src="http://www.example.com/r/c_1,h_478,w_478/2015/03/19/random-celebrities-08-560x560.jpg"> <!--[if ie 9]><video style="display: none;"><![endif]--> <source class='picture-source-1260' srcset='http://www.example.com/r/c_1,h_239,w_239/2015/03/19/random-celebrities-08-560x560.jpg, http://www.example.com/r/c_1,h_478,w_478/2015/03/19/random-celebrities-08-560x560.jpg 2x' media='(min-width: 1260px)'> <source class='picture-source-960' srcset='http://www.example.com/r/c_1,h_180,w_180/2015/03/19/random-celebrities-08-560x560.jpg, http://www.example.com/r/...

c++ - No viable conversion from 'mapped_type' -

this code compare xml files, using map define xml tag names content. #include "pugi/pugixml.hpp" #include <iostream> #include <string> #include <map> using namespace std; int main() { pugi::xml_document doca, docb; std::map<std::string, pugi::xml_node> mapa, mapb; std::map<int, std::string> tagmap {make_pair(1, "data"), make_pair(2, "entry"), make_pair(3, "id"), make_pair(4, "content")}; if (!doca.load_file("a.xml") || !docb.load_file("b.xml")) { std::cout << "can't find input files"; return 1; } (auto& node: doca.child(tagmap[1]).children(tagmap[2])) { auto id = node.child_value(tagmap[3]); mapa[id] = node; } (auto& node: docb.child(tagmap[1]).children(tagmap[2])) { auto idcs = node.child_value(tagmap[3]); if (!mapa.erase(idcs)) { mapb[idcs] = node; ...

While deploying a simple web application, the java file (i.e servlet) doesn't run on server (Tomcat) -

Image
1 there no error in .java file , have created form.html. tomcat working fine, when try run .html runs fine when try run .java file shows error "servlet beerselect not available" whereas have defined it. sorry guys, i'm new here don't have require reputation put pictures. you cannot run .java file on tomcat. should servlet purpose. an example of simple servlet is: package com.jenkov.butterfly; import java.io.ioexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; public class myservlet extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response) throws ioexception { response.getwriter().println("hello"); } } if servlet, might missing mapping in web.xml : <?xml version="1.0" encodi...

node.js - Mongodb, can i trigger secondary replication only at the given time or manually? -

i'm not mongodb expert, i'm little unsure server setup now. i have single instance running mongo3.0.2 wiredtiger, accepting both read , write ops. collects logs client, write load decent. once day want process logs , calculate metrics using aggregation framework, data set process logs last month , calculation takes 5-6 hours. i'm thinking splitting write , read avoid locks on collections (server continues write logs while i'm reading, newly written logs may match queries, can skip them, because don't need 100% accuracy). in other words, want make setup secondary read, replication not performing continuously, starts in configured time or better triggered before read operations started. i'm making processing node.js 1 option see here export data created in period [yesterday, today] , import read instance myself , make calculations after import done. looking on replica set , master/slave replication possible setups didn't how config achieve described...

javascript - AngularJS - Shared service object being deleted incorrectly -

when trigger deletequestion() second time 2 questions deleted. idea? let me know if need see more of code. controller.js crtpromoctrl.controller('surveyctrl', ['$scope', 'surveysrv', function($scope, surveysrv) { $scope.questions = surveysrv.getquestions(); $scope.editquestion = function(index) { surveysrv.seteditquestion(index); }; $scope.deletequestion = function(index) { $(document).off('click', '#confirmationmodal #confirm'); $('#confirmationmodal').modal('show'); $(document).on('click', '#confirmationmodal #confirm', function() { surveysrv.deletequestion(index); $scope.$apply(); }); }; }]); service.js crtpromosrv.service('surveysrv', function() { var questions = []; var editquestion; this.getquestions = function() { return questions; }; this.addquestion...

c# - Pass data between Views in MVC -

i'm working on web application project using c# , mvc take in 2 urls in form , use them create instance of class have created called "imageswap." model has data (a username of person performing swap; 2 variables hold urls of 2 images swapped; 2 variables save actual names of these files without of rest of url information; , 2 arrays represent file locations check these files). right now, have initial index view creates instance of class , passes same view information put in through form, submitted via post, so: public actionresult index() { ops.operations.models.imageswapmodel newimageswap = new models.imageswapmodel(); return view(newimageswap); } [httppost] public actionresult index(imageswapmodel imageswap) { var oldfilefound = false; var newfilefound = false; if (modelstate.isvalid) { //perform data manipulation , set needed values } } it performs functions on data, such parsing out filename @ end ...

ajax - rendered attribute of h:outputLabel not working properly when called from a4j:commandButton click -

this question has answer here: ajax update/render not work on component has rendered attribute 1 answer please me solving issue in jsf 1 change of bean.displayind false true outputlabel not rendering. on click of commandbutton , filterrequest method called sets value of displayind true.but value still coming false , rowcountlabel not working??hardcoding value of rendered attribute true or false working.so issue in render call a4j:commandbutton? <a4j:commandbutton value="filter" action="#{bean.filterrequest}" render="rowcountlabel"/> <h:outputlabel id="rowcountlabel" value="#{bean.rowcount}" rendered="#{bean.displayind}"/> by wrapping h:outputlabel in a4j:outputpanel , rendering solve problem. <a4j:commandbutton value="filter" action="#{bean.filt...

How to get selected text on click of an element in javascript -

i have div [contenteditable=true] attribute. when select text , click button, want selected text. did following: $(".btn").click(function (){ alert(window.getselection()); }); the above code not alert anything. if change .btn element img element, alert outputs selected text. can selected text on click of element thid html code: <li class="btn">selection </li> <div contenteditable="true">some text here</div> when select required text , click button, ramon & adeneo explains in comment, focus lost. button command executed @ mouseup at point selection cleared. far understand, reason why code works image because unlike button image command executed @ mousedown . my suggestion try .on('mousedown', ...) command instead of simple click command.

c# 4.0 - rdlc textbox overlapping each other when text is longer than textbox width -

in rdlc , have several textbox alight top bottom follow : textbox1 textbox2 textbox3 whenever text inside text box longer given width, overlap textbox below , need not overlapping it, push down text box . i have reference http://forums.asp.net/t/1590478.aspx?textbox+with+too+long+text+overlapps+textbox+beneath , solution not working me. my question how should whenever text longer given width of textbox, how prevent overlapping textbox below , or how push text box below ?

Plotting on Image in Python -

i got how plot on image using matplot lib. but, how can add button on same window? there module can plot on image , add buttons on window . if must use matplot lib plotting suggest looking ipython. if data set small enough managed in spreadsheet, xlsxwriter can alternative plotting graphs...

Randomize image in array in sprite kit swift. -

i wondering if show me how make can spawn random image missiles. right using 1 image called "meteor", have few more images show , randomize. know need put them in array , create arc random. have done sound i'm not sure how images. code far. var lastmissileadded : nstimeinterval = 0.0 let missilevelocity : cgfloat = 4.0 func addmissile() { // initializing missile node var missile = skspritenode(imagenamed: "meteor") missile.setscale(0.44) // adding spritekit physics body collision detection missile.physicsbody = skphysicsbody(rectangleofsize: missile.size) missile.physicsbody?.categorybitmask = uint32(obstaclecategory) missile.physicsbody?.dynamic = true missile.physicsbody?.contacttestbitmask = uint32(shipcategory) missile.physicsbody?.collisionbitmask = 0 missile.physicsbody?.usesprecisecollisiondetection = true missile.name = "missile" // selecting random y position missile var random : cgf...

bash - Using an awk script on multiple rows of a file -

i have following file: (not sure why it's not aligned here... in terminal...) name state pay rate hours worked overtime hours john doe mo 13.75 27 0 jane doe ks 21.00 32 0 sam smith mo 32.50 40 8 barb jones mo 28.25 40 16 jenny lind ks 10.50 28 0 so wrote script: #!/bin/awk -f { name=$1" "$2 state=$3 payrate=$4 hoursworked=$5 overtime=$6 grosspay=(hoursworked+(overtime*1.5))*payrate if (state == "ks") tax = grosspay* .07 else if (state == "mo") tax = grosspay* .08 else print "tax info not found" netpay = grosspay-tax } end{ print "name \tstate\n", name, "\t", state, "\ngross pay:\t$", grosspay, "\ntaxes: \t$", tax, "\nnet pay:\t...

java - WinZip is unable to open zipped file prepared using Apache commons compress ApI -

i have scenario zip files , folders (with sub-folders). able achieve using apache commons compress library , this post. have application uses java.util.zip library unzip file. utility not able read apache commons compress zipped folder, first zipentry null. however when zipped file prepared using winzip, utility has no problem in unzipping it. i tried unzip compression zip file using winzip, gives error - unable open local header "filename" . idea how add local header files? checked source code ziparchiveoutputstream , writetolocalheaderfile. any pointers issue? unzip code below: { file destdir = new file(destdirectory); zipinputstream zipin = new zipinputstream(new fileinputstream(zipfilepath)); zipentry entry = zipin.getnextentry(); // iterates on entries in zip file while (entry != null) { string filepath = destdirectory + file.separator + entry.getname(); if (!entry.isdirectory()) { // if entry file, extracts extractfile(zipin, f...

Bootstrap Fullcalendar Storing Object - i add/modify an object at chrome but after i refresh the calendar the changes gone away -

how store object, until decide modify or delete. make change thru web browser dragging in object or click in calendar after refresh page, goes default. boostrap. help $(document).ready(function () { /* initialize external events -----------------------------------------------c ------------------*/ $('#external-events div.external-event2').each(function () { // create event object (http://arshaw.com/fullcalendar/docs/event_data/event_object/) // doesn't need have start or end var eventobject = { title: $.trim($(this).text()) // use element's text event title }; // store event object in dom element can later $(this).data('eventobject', eventobject); // make event draggable using jquery ui $(this).draggable({ zindex: 999, revert: true, // cause event go revertduratio...

php - Mutual SSL using CA issued certificates -

i'm trying find straight forward method mutual ssl between servers, using ca issued certificates. of information i've found involves issuing self-signed certs clients, storing certs, etc. there reliable method doing 2 way ssl using existing ca issued certs? (i'm developing in lamp environment btw.) the difference between self-signed , ca issued isn't once cert creation done. in both cases need have client pass certificate during ssl handshake , have server validate cert , use login remote user. when go server-to-server, treat originating server client , destination server server. same going client machine server machine. depending on exact authentication/authorization model you're using, may need create "user" account on destination server originating server may seem odd have user account server, simplifies security model not needing special case call server. i'm not php expert looks reasonable reference lamp mutual authentication....

c - bit-shifting by an integer value -

this code cache simulator project - trying extract bits memory address. when attempt use int variables bit shifting, end incorrect result, when use numbers directly, result correct. i've been looking on answer this, can't find one. issue here? #include <stdio.h> void main(){ unsigned long long int mem_addr = 0x7fff5a8487c0; int byte_offset_bits = 2; int block_offset_bits = 5; int index_bits = 8; int tag_bits = 33; unsigned long long int tag1 = (mem_addr&(((1<<33)-1)<<(2+5+8)))>>(2+5+8); unsigned long long int tag2 = (mem_addr&(((1<<tag_bits)-1)<<(byte_offset_bits + block_offset_bits + index_bits)))>>(byte_offset_bits + block_offset_bits + index_bits); printf("%s %llx\n", "tag 1:", tag1); printf("%s %llx\n", "tag 2:", tag2); } the output is: tag 1: fffeb509 tag 2: 1 i getting warning line computes tag1 correctly, doesn't make sense m...

python - How to count the number of times a value is in a column based on particular row values? -

i have data frame: outlook temperature playtennis value 0 sunny 60 yes 1 1 sunny 70 yes 1 2 sunny 40 no 1 3 overcast 40 no 1 4 overcast 60 yes 1 5 overcast 50 yes 1 6 overcast 70 yes 1 7 overcast 80 yes 1 8 rain 65 no 1 9 rain 70 yes 1 and want this outlook yes no sunny 2 1 overcast 4 1 rain 1 1 not sure commands use count yesses , nos based on sunny/overcast/rain how's this? df.groupby('outlook').apply(lambda g: g['playtennis'].value_counts()) or, exact spec: df.groupby('outlook').apply(lambda g: g['playtennis'].value_counts()).unstack(1) or shorter: d...

xml - Xproc: passing a dynamic href to <p:http-request> -

i have pipeline runs xslt on input, doing put of result database via <p:http-request> step. the tricky bit here need build dynamic href using metadata output of <p:xslt> xml. pseudo code here of i'm trying achieve: <p:xslt name="xslt1"> <p:input port="stylesheet"> <p:document href="xslt-1.xslt" /> </p:input> </p:xslt> <p:variable name="href" select="concat('http://localhost:8000/myrestendpoint?uri=/mydb/', /*/@name, /*/@number,'.xml')"/> <p:sink /> <p:insert position="first-child" match="c:body"> <p:input port="source"> <p:inline> <c:request href="{$href}" auth-method="basic" ...

multithreading - Safe Way to Limit Running Threads C# -

i have program writing run variety of tasks. have set have called "task queue" in continually grab next task process (if there one) , start new thread handle task. however, want limit amount of threads can spawn @ 1 time apparent reasons. created variable keep max threads spawn , 1 current thread count. thinking of using lock try , accurately keep current thread count. here general idea. public class program { private static int mintthreadcount; private static int mintmaxthreadcount = 10; private static object mobjlock = new object(); static void main(string[] args) { mintthreadcount = 0; int = 100; while(i > 0) { startnewthread(); i--; } console.read(); } private static void startnewthread() { lock(mobjlock) { if(mintthreadcount < mintmaxthreadcount) { thread newthread = new thread(starttask); newthread.start(mintthreadcount); mintthreadcount++; } e...

git - Export author mapping in Stash SVN Mirror -

i building stash server migrate our svn projects git. currently experimenting trial stash , svn mirror plugin importing of our projects. the point following: while ldap mapping working , commits have been consistent users, people left company no more registered in our ldap, decided manually type old email sake of completeness git author mapping screen appears when prepare project importing. since it's repeated work, export author mapping file missing entried import in plugin's global configuration screen. the question is: do know how can export svn<->git authors file either existing git repository made in stash svn import or during wizard itself? useful there's no ui option export authors mapping file, however, can find file on stash server @ following location: stash_home/shared/data/repositories/repo_id/subgit/authors.txt make sure corresponding git repository active mirror. can find path git repository on repository settings | repositor...

c++ - Removing multiple elements from stl list while iterating -

this not similar can remove elements std::list while iterating through it? . mine different scenario. lets have list this. 1 2 3 1 2 2 1 3 i want iterate stl list in such way when first encounter element x activity , need remove elements x in list , continue iterating. whats efficient way of doing in c++. i worried when remove or erase invalidating iterators. if 1 element potentially increment iterator , erase. in scenario need delete/erase occurances. was thinking this while (!list.empty()) { int num = list.front(); // activity , if successfull list.remove(num); } dont know if best. save set of seen numbers , if encounter number in set ignore it. can follows: list<int> old_list = {1, 2, 3, 1, 2, 2, 1, 3}; list<int> new_list; set<int> seen_elements; for(int el : old_list) { if (seen_elements.find(el) == seen_elements.end()) { seen_elements.insert(el); new_list.push_back(el); } } return new_list; this proces...

python - No JSON object could be decoded for the web APIs -

i new python, , repeating solved examples book "python data analysis" in 1 example, need access apis twitter search. here code: import requests url='https://twitter.com/search?q=python%20pandas&src=typd' resp=requests.get(url) everything works okay here. problems comes when use json import json data=json.loads(resp.text) then received error message valueerror: no json object decoded i tried switch url instead of twitter, still receive same error message. does have ideas? thanks you need response json content. search twitter requires use of api.twitter.com, need oauth key. it's more complicated 5 lines of code have. see http://nbviewer.ipython.org/github/chdoig/mining-the-social-web-2nd-edition/blob/master/ipynb/chapter%201%20-%20mining%20twitter.ipynb

php - Yii2 cancel validation on the javascript side -

i need can opportunity enable/disable validation form on javascript side on event click example. use activerecord creating form. you should set enableclientvalidation false : $form = activeform::begin([ 'enableclientvalidation' => false, ]); read more : http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html#$enableclientvalidation-detail

python - Bottle server not responding while calculating -

i have bottle server running on port 8080, using "gevent" server. use server support simple "server sent events". my question related not knowing how set working. hope can take time elaborate on this. all routes , serving of files server working great, have issue when accessing specific route "/get_data". gathers data web internal data sources. gathering takes 30 minutes. while process running, not able access routes on server, i.e. "/" or "/login". once process finished, works again , database updated gathered information. i tried replacing gathering algorithms simple time.sleep(60), , while timer active, still able access other routes fine. this leads 2 questions: why not able access server while process running. port blocked (from reading web-information), or maybe has threading? what best way run demanding / long process on server? preferably access web app, have thought putting in seperate python file , run localy o...

rounding - Round IO Double to specified number of digits - Haskell -

is there way round io double ? looking function: ownround :: io double -> io double with these unit tests: ownround 0.51 == 0.5 ownround 0.49 == 0.5 ownround 0.5 == 0.5 ownround 0.7132 == 0.7 ownround 0.39 == 0.4 what asking can't had. test cases you've written function tensround :: double -> double but type signature wrote function ownround :: io double -> io double if meant write test cases as ownround (return 0.51) == return 0.5 ownround (return 0.49) == return 0.5 and on, every number wrapped io, these implementations work: tensround :: double -> double tensround d = frominteger (round (d*10)) / 10 ownround :: io double -> io double ownround = fmap tensround

sql server 2008 - SQL Multiple dynamic queries to one query -

i working in sql server 2008 environment sql server management studio 2012. i have written 3 separate queries query 1 sql query sums stock on hand inventories table select stockcode, sum(qtyonhand) 'soh' invwarehouse stockcode not '%dem%' , stockcode not '%ref%' , stockcode not 'z%' group invwarehouse.stockcode query 2 this query looks @ future orders purchase orders table , dynamically returns next/following 12 months declare @cols nvarchar(max), @cols1 nvarchar(max), @cols2 nvarchar(max), @cols3 nvarchar(max), @query nvarchar(max) select @cols = stuff((select ',' + quotename(yearmonth) -- selecting using destinct -- (select distinct cast(year([orderduedate]) nvarchar(4)) + right('00' + cast(month([orderduedate]) nvarchar(2)),2) yearmonth pormasterhdr join pormasterdetail ...