|
-
Apr 9th, 2007, 07:24 AM
#1
Thread Starter
Addicted Member
[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
-
Apr 9th, 2007, 07:54 AM
#2
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...
-
Apr 9th, 2007, 08:10 AM
#3
Thread Starter
Addicted Member
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?
-
Apr 9th, 2007, 08:17 AM
#4
Re: [2005] Which command?
What exactly do you need to accomplish?
-
Apr 9th, 2007, 08:23 AM
#5
Re: [2005] Which command?
select count(ID2) from mytablename
-
Apr 9th, 2007, 08:27 AM
#6
Thread Starter
Addicted Member
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
-
Apr 9th, 2007, 08:30 AM
#7
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.
-
Apr 9th, 2007, 08:54 AM
#8
Thread Starter
Addicted Member
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?
-
Apr 9th, 2007, 10:02 AM
#9
Thread Starter
Addicted Member
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?
-
Apr 9th, 2007, 05:50 PM
#10
Thread Starter
Addicted Member
Re: [2005] Which command?
-
Apr 9th, 2007, 07:46 PM
#11
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|