BobRodes's Profile User Rating: *****

Reputation: 545 Enlightened
Group:
Expert
Active Posts:
2,917 (2 per day)
Joined:
19-May 09
Profile Views:
22,734
Last Active:
User is offline Today, 01:31 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Mac
Favorite Browser:
Safari
Favorite Processor:
Who Cares
Favorite Gaming Platform:
XBox
Your Car:
Mercedes
Dream Kudos:
0
Expert In:
VB6/VB.NET

Latest Visitors

Icon   BobRodes is in a constant state of expansion, while getting thinner sometime later.

Posts I've Made

  1. In Topic: What is a short version of this code? Group by day and another field.

    Posted 19 May 2013

    What you're saying is that you want to eliminate duplicate values first, and then count the result. To do this, use the DISTINCT keyword in your nested select, and then do the count on the result. So, like this:
    SELECT tt.PrimaryID, DATEPART(MONTH, TestDate) AS [Month], Count(tt.TestDate) FROM 
       (SELECT DISTINCT PrimaryID, TestDate FROM ThisTable) tt
    GROUP BY PrimaryID, DATEPART(MONTH, TestDate)
    


    In other words, yes, there is as you suspect a short version of your code. :)
  2. In Topic: COUNT in an sql querry

    Posted 19 May 2013

    Count counts how many records you have. It doesn't "count" the numbers in the fields. It also doesn't include null values the way you have it. So, you would use count to find the number of records that have a value in each column that you are counting. That's obviously not what you want to do; you want to add the values in each column. That's sum, not count.

    Next, if you want them by Month, that's where Group By comes in. Look up the datepart function, include it at the beginning of your select query as a column, and include the same function in your group by clause.
  3. In Topic: Fill in a null column when data is submitted on sql server 2008

    Posted 19 May 2013

    You're able to stick a literal value into a select query: SELECT Title, Price, 1 from tblCart. (This will tack a column on the end of your query result that always has the value of 1.) So, for your line 5:
        String cmdString = "INSERT INTO tblPurchaseItem(Title, Price) Select Title, Price, " + purID + " from tblCart";
    
    Assuming that purID is an integer. If not, you'll have to enclose the variable in single quotes:
        String cmdString = "INSERT INTO tblPurchaseItem(Title, Price) Select Title, Price, '" + purID + "' from tblCart";
    
    which you can do anyway if you like.
  4. In Topic: Execution Plan

    Posted 19 May 2013

    You can put two different ways to execute the same query side by side, and the execution plan will tell you what percentage of time each one will take.
  5. In Topic: entity relationship diagram for eprint repsitory database

    Posted 19 May 2013

    Why don't you ask eprints? www.eprints.org has an email for requests like this.

My Information

Member Title:
Your Friendly Local Curmudgeon
Age:
56 years old
Birthday:
September 15, 1956
Gender:
Location:
Tullahoma, Tennessee
Interests:
IT, Music.
Forum Leader:
VB6, VB.NET
Full Name:
Bob Rodes
Years Programming:
25
Programming Languages:
BASIC, VB6, VB.Net, C#, Java, Javascript, CSS, also UML

Contact Information

E-mail:
Click here to e-mail me

Comments

Page 1 of 1
  1. Photo

    lucky3 Icon

    31 Dec 2012 - 02:30
    Congratulations for the "Expert of the Year" 1st place award!
  2. Photo

    Elda Icon

    23 Jul 2012 - 19:09
    Congratulations. You're an expert. you deserved it. :)
  3. Photo

    trevster344 Icon

    15 Jun 2012 - 17:53
    I found your post in the thread, that is now locked in the .net forum, to be quite humorous. Just wanted to say I appreciate your work and effort helping people out, because sometimes I don't have the patience myself to sit there spoon feeding people information. Thanks :)
  4. Photo

    15Dhan Icon

    01 May 2012 - 18:15
    Congrats .. IDOL :)
  5. Photo

    haidar976 Icon

    18 Aug 2011 - 23:55
    How can you manage all these languages without be confusing between them? I tried to learn C++ then after few months changed to VB6 I completely forgot every thing about C++, I cant work with two language in the same time
    You are expert man
  6. Photo

    BobRodes Icon

    15 Feb 2011 - 15:02
    Thanks for the recognition. I'm honored.
  7. Photo

    Dogstopper Icon

    14 Feb 2011 - 19:35
    Congratulations on Expert!
Page 1 of 1