Saturday, June 15, 2013

[SQL Server] Simple Program

[SQL Server] Simple Program


Simple Program

Posted: 14 Jun 2013 05:47 PM PDT

I am in the process of learning how to put together simple programs to iterate over a table dataset and report various information from that table. To do this I am using a temporary table. I though have not figured out yet how to program a second pass through the temporary table. Can someone help me with the principles I am missing in this. I am working through a book but haven't gotten there yet. Just a little impatient and want to know the solution before reading through it. Here is my dataset, code and results. My results do not reflect sorted results which I will correct, I would like to know why I cannot get the "TYPE" field populated.Year Month Day Hour Minute Second MilisecondAsk Bid AskVolumeBidVolume2013 01 02 01 33 29 095 1.32277 1.32264 1.5 2.482013 01 02 01 33 29 955 1.32277 1.32264 1.5 2.482013 01 02 01 33 30 315 1.32277 1.32266 1.5 1.52013 01 02 01 33 30 859 1.32277 1.32264 1.5 2.482013 01 02 01 33 31 325 1.32277 1.32266 1.5 1.52013 01 02 01 33 31 625 1.32277 1.32266 1.5 2.252013 01 02 01 33 32 506 1.32277 1.32266 1.5 1.52013 01 02 01 33 32 855 1.32277 1.32266 1.5 1.52013 01 02 01 33 36 865 1.32278 1.32264 1.5 2.482013 01 02 01 33 53 035 1.32278 1.32266 2.25 1.52013 01 02 01 33 55 105 1.32278 1.32266 2.25 1.52013 01 02 01 33 56 096 1.32278 1.32266 2.25 1.52013 01 02 01 34 04 022 1.32275 1.32266 2.25 1.52013 01 02 01 34 04 216 1.32274 1.32263 1.35 1.882013 01 02 01 34 04 754 1.32275 1.32263 1.5 1.88[code="sql"]USEEURUSDGODECLARE @Status char(6), @Vol float(5)DECLARE @TestTable TABLE (Type char(6), Volume float(4)) BEGIN INSERT INTO @TestTable (Volume) SELECT BidVolume FROM EURUSD#1ENDBEGIN SELECT @Vol = Volume FROM @TestTable IF @VOL > 0 INSERT INTO @TestTable (Type) VALUES('OK') ELSE INSERT INTO @TestTable (Type) VALUES('NOTOK') SELECT Volume, Type FROM @TestTableEND[/code]Query Results----------------------------------Volume TypeNULL OK 2.25 NULL1.88 NULL1.65 NULL2.4 NULL1.65 NULL1.5 NULL1.5 NULL1.65 NULL1.65 NULL

Need to select specific Application version if machine has multiple times same application installed

Posted: 15 Jun 2013 02:14 AM PDT

need some help with the following. I'm using dummy data below to explain what I need.I've got table that contains information about applications installed on workstation. In our environment applications go through 3 phases (Alpha; Beta; Production) if all goes well when user has Alpha installed, it should automatically upgrade to Beta and then to Production so when we run report it should only show 1 version of specif application installed. like I said if all goes well :-)we have found instances where workstation has 2 versions installed of same application and we want to filter out the latest versiontable has 3 columns machineID, AppName, ApplicationInfomachineID integer valueAppName string (ShortName for the application)ApplicationInfo string (FullName for the application including version)Example 1machineID AppName ApplicatonInfo1 MSOffice2010 MSOffice2010/Alpha1 MSProject2010 MSProject2010/Beta1 MSVisio2010 MSVisio2010/Prod1 MSVisio2010 MSVisio2010/BetaIn the example above I only want to report MSVisio2010/Prod (I don't care about the Beta in our environment this is 1 installation)Example 2machineID AppName Applicaton1 MSOffice2010 MSOffice2010/Alpha1 MSOffice2010 MSOffice2010/Beta1 MSVisio2010 MSVisio2010/ProdIn the example above I only want to report MSOffice2010/Beta (same comments as before, don't care about the Alpha)To summarize few scenario'sif machine has Alpha And Beta installed need to report Betaif machine has Beta And Prod installed need to report Prodif machine has Alpha, Beta and Prod installed need to report Prod

No comments:

Post a Comment

Search This Blog