query to fetch same row by different words in sqlite - sqlite

I am new be in database programming .I have to fetch same row from different where word for example I have 2 column keywords and data in keywords there may be more than one words Profit ,profits,revenue but data column have only one entry
keywords data
Profit, Profits, revenue It is increasing
Now when user enter profit or profits or revenue then he/she get same data " It increasing"
Could you provide me query .
Thanks in advance

Use LIKE: SELECT data FROM table WHERE keywords LIKE '%Profit%';

Related

Counting Columns in ColdFusion's QoQ

I have:
<cfspreadsheet action="read" src="#Trim(PathToExcelFile)#" query="Data">
How do I count the total column in my "Data" query using ColdFusion Query of Query? I need to count whether my users has used the corrent excel file format before inserting into my DB.
I'm using Oracle 11g and I can not do:
Select * From Data Where rownum < 2
If I can do that then I can create an array and count the columns but running that script using results in error. The error saying that there is no column name Rownum. Oracle does not allow me to use select top 1.
I don't want to loop over 5000+ record to just count the total column of one row. I appreciate any help, thank you
ColdFusion adds a few additional variables to it's query results. One of them is named `columnList' and contains a comma-separated list of the query columns that were returned.
From the documentation here
From that you should be able to count the number of columns easily. #listlen(Data.columnList)# as one example.

Returning the number of products in a database

I have made a database with the columns, Product, Quantity, Size and Units. There are 4 products in my db. What would I use if I wanted to return the quantity of a product in the database?
Say I have Bread in my products and have a quantity of 5. How would I get my cmd to output that I have 5 loaves of bread?
select quantity, size, units from {table name} where product = 'bread'
That should get you started.
Note that you're using the word database to mean table. A relational database like sqlite contains one or more tables that hold your data in rows

Get values from 5 columns meeting specific conditions from 2 other columns - SQL query in Access

I am new here.
I am using MS-Access and I have a database with several columns. Here is what I have and what I am looking for.
A column has a list of names. There are multiple entries for each name.
Another column has a list of dates. I should be able to select the most recent date for each of the names.
I know the SQL query for doing this in Access.
My challenge lies here. I have 5 other columns with status info. Either it's P or F or NA.
For each name and the most recent date, I should be able to pick the column names from the 5 status columns that equal F (status=fail).
How do I write a SQL query in Access to do that?
So, I think I got the first part.
SELECT O.* FROM data O
INNER JOIN
(SELECT I.[Name], MAX(CreatedDate) As RecentDate FROM data I
GROUP BY I.[Name])I
ON I.[Name] = O.[Name] AND I.RecentDate = O.CreatedDate
Now that I think about it, the second part seems very hard to me. The user should be able to select Name and then see the most recent date and the corresponding status column names if the status shows up as "F".

Access query to include all records even if 1 field has missing data

How can I get MS Access 2010 to include data in a query if 1 field has missing data.
IE: I have a sn column in tblPropertydevices and a sn column in tblBrentwoodID that is imported from another source. If there is a typo in the imported data sn column, the entire report is not printed.
I would like for the report to print all reports & ignore the missing data in the one column. I have tried "<>"" Or is null" in the criteria for that column wth no results.
The query pulls data from several tables and prints test reports based on date tested and tech#. That is the only 2 fields that absolutely have to match.
Found the solution.
All you have to do is click on the relationship line in the query and select the 2nd radio button to include all records from the firs table.
Too easy
Toby

How to create database table dynamically and insert data selected by query

I'm working on website where I need to find rank of user on the basis of score. Earlier I'm calculating the score and rank of user by sql query .
select * from (
select
usrid,
ROW_NUMBER()
OVER(ORDER BY (count(*)+sum(sup)+sum(opp)+sum(visited)*0.3) DESC) AS rank,
(count(*)+sum(sup)+sum(opp)+sum(visited)*0.3 ) As score
from [DB_].[dbo].[dsas]
group by usrid) as cash
where usrid=#userid
Please don't concentrate more on query because this is only to explain how I select data.
Problem: Now I can't use above query because every time I use rank it need to select rank from dsas table and data of dsas table is increasing day by day and slows down my website.
What I need is select data by above query and insert in another table named as score. Can we do anything like this?
A better solution is to either include score as a field in your user table or have a separate table for scores. Any time you add new sup, opp, or visited data for a user, also recalculate their score at that time.
Then to get the highest ranking users, you will be able to perform a very simple select statement, ordering by score descending, and only fetching the number of rows you want. It will be very fast.

Resources