question

ravikumar-1532 avatar image
0 Votes"
ravikumar-1532 asked pituach commented

Filter and mutliply sql table with stored procedure

Hello all,

I am very new to SQL ,

I have table like this :

195784-image.png

in my winform I have two text boxes for Dish & number of persons:
so if i type Cake & 3 , the result should be like below :
195764-image.png

Pls someone guide me how to achieve the same.


sql-server-generalwindows-forms
image.png (7.4 KiB)
image.png (4.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

pituach avatar image
0 Votes"
pituach answered pituach commented

Hi ravi and welcome to the QnA forums

I am very new to SQL , I have table like this :

First step in the right way to learn well is to learn how to ask questions :-)

What you provide is image and not table. We cannot demonstrate execution on images. What you need to provide in each question is a DDL+DML. In short, we need queries to create the table and top insert some sample data and not images. If this answer will not cover your needs then please provide the missing information.

in my winform I have two text boxes for Dish & number of persons: so if i type Cake & 3 , the result should be like below :

There 2 actions which you try to do on the data from the table: (1) Filter only rows with Dish = 'Cake' and (2) You want to multiply the value in the column Qty by 3 or in other words you want to get Qty*3

SQL language is based on English and all you need to do is to write these 2 action exactly as it sound in English, which why SQL language was designed for any child from the age that he can read and write English will be able to learn the language in a few days

So... let's see the code

 SELECT 
     Dish,               -- this is what you want to get in the first column in the result
     Ingedient,       -- this is what you want to get in the second column in the result
     Qty*3              -- this is what you want to get in the third column in the result: Qty multiply by 3 
 FROM Table_Name
 -- And now we can add the filters
 WHERE Dish = 'Cake'

You should go over a simple course online to learn SQL. It should not take more than a few days including the exercise. You can start with the tutorial: https://www.w3schools.com/sql/





· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you so much ... I leaned from your inputs and completed the query with additional conditions and group by to summarise in a neat way... thank you again

1 Vote 1 ·
pituach avatar image pituach ravikumar-1532 ·

You are most welcome

Glad I could help a bit :-)

0 Votes 0 ·