Results 1 to 11 of 11

Thread: [2005] Which command?

  1. #1

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Question [2005] Which command?

    I am tring to make a query but I am a beginner in SQL commands. Example is following:

    There is the table which is my database and Query will look like that. I have added everything to picture.

    I am using MS SQL 2005
    (Sorry about my english)

    Thanks for every kind of help
    Dim Me As Coder

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] Which command?

    The smart tags in VB2005 make it very easy to generate SQL statements. If you could give us a better idea of what you're after, then we can help you with a specific task...

  3. #3

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Re: [2005] Which command?

    If you could give us a better idea of what you're after, then we can help you with a specific task...
    Sorry I dont understand that phrase?
    Dim Me As Coder

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] Which command?

    What exactly do you need to accomplish?

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] Which command?

    select count(ID2) from mytablename

  6. #6

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Re: [2005] Which command?

    i added that in picture:
    I want to see in my datagrid view:

    ID2* | Count of rows with ID2 | Count of rows with option=1 | Count of rows with option=2

    * There are lots of ID2 values and I will use "DISTINCT" to see only one ID2 per 1 row

    Command will be like this:
    SELECT ID2 DISTINCT,Count(......),COUNT(.......),COUNT(.......) From Table
    Dim Me As Coder

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] Which command?

    As for the other query:

    select count(*) from tablename where option = 1

    SQL's not complicated. I suggest you invest some time in a tutorial.

  8. #8

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Re: [2005] Which command?

    yeah I know w3school tutorials and I know that SQL is not complicated I learned it alone from that website but the code which you have written gives me only one integer. But I want rows...
    SELECT ID2 DISTINCT,Count(......),COUNT(.......),COUNT(.......) From Table
    in this code there are 4 columns. I cant use count function as a column how can I do that?
    Dim Me As Coder

  9. #9

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Re: [2005] Which command?

    This shall be shown in Datagridview
    ID2___Count_____ID2 with Option=1_____ID2 with Option=2
    1_____5_________3___________________2
    2_____4_________0___________________0
    3_____6_________1___________________2
    4_____4_________2___________________1
    How to do this with SQL?
    Dim Me As Coder

  10. #10

    Thread Starter
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Re: [2005] Which command?

    noone knows?
    Dim Me As Coder

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Which command?

    Writing SQL queries has nothing to do with VB.NET, even if they're being executed from a VB.NET application. SQL is database programming and therefore questions regarding it belong in the Database Development forum.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width