Help with SQL statement!

Hi im trying to write a SQL statement. I have attached a copy of the relationhips windows so you will understand.

In the InterComp table I want to add up all InterComp_Quantity fields and also the InterComp_Cost. Which is easy. The problem is I want to group them by month i.e show the total Quantity and cost for each month and obvously I need to be able to seperate the years (In other words I dont want Jan 05 and Jan 06 added together I need Jan 05 & 06 totals shown seperately!).

Is this possibly

Posted On: Monday 19th of November 2012 11:53:57 PM Total Views:  122
View Complete with Replies

Related Messages:

Will pay $$$ through paypal for SQL help - pay you as soon as your done !   (102 Views)
I am willing to pay anyone $20 instantly through paypal to do the following problems... (True/False) 1. A simple view is based on a single table. 3. In a sequence, to get the current value with CURRVAL, atleast one number must be generated first by using NEXTVAL. 11. A sequence can be used only on the one table for which its created. 14. CURRVAL returns the START WITH value of a sequence for a sequence that is created but is never used to generate a value. 15. When a view is dropped, the underlying table is also dropped. 16. When a table is dropped, the sequence used on that table also is dropped. NOTE: For views also show the select statement using the view and the results. LAB activity 1, 2, 4, 9 and 10 1. Create a view to include all employee information, but hide salary and commission. 2. Create a view to include department name and average salary by department. 4. Create a sequence to add room IDs, and then insert a new room into the LOCATION table using the newly created sequence. What is the CURRVAL after the new row is inserted 9. Create a view that will display department names and the sum of all employee income by department. 10 Create a sequence deptid_seq to generate department Id (in the DEPT table) and another sequence empid_seq to generate employee Id (in the EMPLOYEE table). Use deptid_seq to add a new department in the DEPT table. Now, add yourself as a new employee with empid_seq in the department you just added. The lab exercises can be done using the N2.sql database below. If you get this done by tonight I'll pay even more ! email me at toly6 @ (no spaces) ALTER TABLE emplevel Drop primary Key cascade; ALTER TABLE qualification Drop primary Key cascade; ALTER TABLE employee Drop primary Key cascade; ALTER TABLE dept Drop primary Key cascade; ALTER TABLE dependent Drop primary Key cascade; ALTER TABLE position Drop primary Key cascade; Drop table emplevel; Drop table qualification; Drop table employee; Drop table dept; Drop table dependent; Drop table position; CREATE TABLE emplevel (LevelNo NUMBER (1), LowSalary NUMBER (6), HighSalary NUMBER (6), CONSTRAINT emplevel_levelno_pk PRIMARY KEY (LevelNo)); CREATE TABLE position (PositionId NUMBER (1), PosDesc VARCHAR2 (10), CONSTRAINT position_positionid_pk PRIMARY KEY (PositionId)); CREATE TABLE qualification (QualId NUMBER (1), QualDesc VARCHAR2 (11), CONSTRAINT qualification_qualid_pk PRIMARY KEY (QualId)); CREATE TABLE dept (DeptId NUMBER (2), DeptName VARCHAR2 (12) NOT NULL, Location VARCHAR2 (15), EmployeeId NUMBER (3), CONSTRAINT dept_deptid_pk PRIMARY KEY (DeptId)); CREATE TABLE employee (EmployeeId NUMBER (3), Lname VARCHAR2 (15) CONSTRAINT employee_lname_nn NOT NULL, Fname VARCHAR2 (15) CONSTRAINT employee_fname_nn NOT NULL, PositionId NUMBER (1), Supervisor NUMBER (3), HireDate DATE, Salary NUMBER (6), Commission NUMBER (5), DeptId NUMBER (2) NOT NULL, QualId NUMBER (1), CONSTRAINT employee_employeeid_pk PRIMARY KEY (EmployeeId), CONSTRAINT employee_positionid_fk FOREIGN KEY (PositionId) REFERENCES position (PositionId), CONSTRAINT employee_deptid_fk FOREIGN KEY (DeptId) REFERENCES dept (DeptId), CONSTRAINT employee_qualid_fk FOREIGN KEY (QualId) REFERENCES qualification (QualId)); CREATE TABLE dependent (EmployeeId NUMBER (3), DependentId NUMBER (1), DepDOB DATE, Relation VARCHAR2 (8), CONSTRAINT dependent_empiddepid_pk PRIMARY KEY (EmployeeId, DependentId), CONSTRAINT dependent_employeeid_fk FOREIGN KEY (EmployeeId) REFERENCES employee (EmployeeId)); INSERT INTO position VALUES (1, 'President'); INSERT INTO position VALUES (2, 'Manager'); INSERT INTO position VALUES (3, 'Programmer'); INSERT INTO position VALUES (4, 'Accountant'); INSERT INTO position VALUES (5, 'Salesman'); INSERT INTO emplevel VALUES (1, 1, 25000); INSERT INTO emplevel VALUES (2, 25001, 50000); INSERT INTO emplevel VALUES (3, 50001, 100000); INSERT INTO emplevel VALUES (4, 100001, 500000); INSERT INTO qualification VALUES (1, 'Doctorate'); INSERT INTO qualification VALUES (2, 'Masters'); INSERT INTO qualification VALUES (3, 'Bachelors'); INSERT INTO qualification VALUES (4, 'Associates'); INSERT INTO qualification VALUES (5, 'High School'); INSERT INTO dept VALUES (10, 'Finance', 'Charlotte', 123); INSERT INTO dept VALUES (20, 'InfoSys', 'New York', 543); INSERT INTO dept VALUES (30, 'Sales', 'Woodbridge', 135); INSERT INTO dept VALUES (40, 'Marketing', 'Los Angeles', 246); INSERT INTO employee VALUES (111, 'Smith', 'John', 1, NULL, TO_DATE ('04/15/1960', 'mm/dd/yyyy'), 265000, 35000, 10, 1); INSERT INTO employee VALUES (246, 'Houston', 'Larry', 2, 111, TO_DATE ('05/19/1967', 'mm/dd/yyyy'), 150000, 10000, 40, 2); INSERT INTO employee VALUES (123, 'Roberts', 'Sandi', 2, 111, TO_DATE ('12/02/1991', 'mm/dd/yyyy'), 75000, NULL, 10, 2); INSERT INTO employee VALUES (433, 'McCall', 'Alex', 3, 543, TO_DATE ('05/10/1997', 'mm/dd/yyyy'), 66500, NULL, 20, 4); INSERT INTO employee VALUES (543, 'Dev', 'Derek', 2, 111, TO_DATE ('03/15/1995', 'mm/dd/yyyy'), 80000, 20000, 20, 1); INSERT INTO employee VALUES (200, 'Shaw', 'Jinku', 5, 135, TO_DATE ('01/03/00', 'mm/dd/yy'), 24500, 3000, 30, NULL); INSERT INTO employee VALUES (135, 'Garner', 'Stanley', 2, 111, TO_DATE ('02/29/1996', 'mm/dd/yyyy'), 45000, 5000, 30, 5); INSERT INTO employee VALUES (222, 'Chen', 'Sunny', 4, 123, TO_DATE ('08/15/1999', 'mm/dd/yyyy'), 35000, NULL, 10, 3); INSERT INTO dependent VALUES (543, 1, TO_DATE ('09/28/1958', 'mm/dd/yyyy'), 'Spouse'); INSERT INTO dependent VALUES (543, 2, TO_DATE ('10/14/1988', 'mm/dd/yyyy'), 'Son'); INSERT INTO dependent VALUES (200, 1, TO_DATE ('06/10/1976', 'mm/dd/yyyy'), 'Spouse'); INSERT INTO dependent VALUES (222, 1, TO_DATE ('02/04/1975', 'mm/dd/yyyy'), 'Spouse'); INSERT INTO dependent VALUES (222, 2, TO_DATE ('08/23/1997', 'mm/dd/yyyy'), 'Son'); INSERT INTO dependent VALUES (222, 3, TO_DATE ('07/10/1999', 'mm/dd/yyyy'), 'Daughter'); INSERT INTO dependent VALUES (111, 1, TO_DATE ('12/12/1945', 'mm/dd/yyyy'), 'Spouse'); ALTER TABLE dept ADD CONSTRAINT dept_employeeid_fk FOREIGN KEY(EmployeeId) REFERENCES employee(EmployeeId); ALTER TABLE employee ADD CONSTRAINT employee_supervisor_fk FOREIGN KEY(Supervisor) REFERENCES employee(EmployeeId);
Please help! stuck with this for ONE whole day!   (122 Views)
Hi all, I have 2 tables: - Company - Contacts The company table stores: - CompanyID - AccountA_status (will be I for inactive, C for customer, D for debtors) - AccountB_status (same as above) The contacts table stores: -ContactID -CompanyID -Contact_name -contact_tel -equipment_Buyer (true or false) -spares_buyer (true or false) -machines_buyer (true or false) it's basically the contact point for the company, and they can be more than one type of buyers And my task is to create a mailing list of the contacts according to: a) AccountA_status b) AccountB_status c) types of buyers so in the form i have 2 groups of radio buttons for the accounts status, and 3 check boxes for the 3 types of buyers. The problem is i haven't a clue how to write the sql statement............... it's actually a lot more difficult than i thought it'd be, can anyone shed some lights
Newbie need help with SQL   (159 Views)
I 'm working on a project and i can't seem to figure out how to do the queries, i have attached the database file. Basically i need to finish question #3 and then complete #4 completed. They are completed using Oracle. Any help is surely appreciated. The expected output is listed below. *******************Questions****************** Question 3 Give the name of the pet(s) that has visited the vets on the most occasions. Output only the pet name(s). Question 4 Give the names of the two pets that have cost the most in vets bills. Output only the pet name(s). Hint: you will need to research the use of the rownum column for it.
Max() function help   (106 Views)
Can someone please help me out. if one has a table of 4 rows with a date column 'salary' and max(salary) returns the largest salary, Is there a variation of max(salary) that could return the second largest salary
help with updatetext function   (106 Views)
Hi ! I want to know how I should write a query with updatetext function. I have ntext field in which I need to find and replace one email address with another one. I have to do this in one column in many rows. Please help me!
What's wrong?pls help   (120 Views)
hey, i dunno what's wrong with this query, i tried running it but nothing was return (there r exisitng records)! is it becos there are 2 conditions for gradewen i tried running it based one condition it works.i need two condition cause the statement is something like Grade is greater and equals. "Select Count(*) as ct from ABSSubGrade where Grade > " 1.4 " AND Grade = " 1.4 " AND ABSID = "&rs1("ABSID")&"" can anybody assist me
Need help with SQL Querey or Stored Procedure   (97 Views)
everyvery body....I am in the process of converting a database driven site from Access to MS SQL Server 2000. Everything works fine but I am having trouble with dates. As we know Access has a way to store a Date and a seperate way to store the time. SQL does not. It handles both items as a Datetime data type. In the code below I have the variable todaydt assigned to now(). which makes it a string and SQL will not accept it into a datetime field as a string. So I need to convert it to datetime format. I have found several websites that talk about stored procedures and using it to convert the string to a date format sql will except, but I have know idea how to apply that to my sql statement below. For more information after it inserts this information into the database it contunues to use the information to insert into other tables after an inner join or two...these new tables will also require the same date. It then pulls information based on the date and time submitted to pass back to an autoresponse page. I know big explanation but I wanted to be thorough.... So how do I convert the string to a datetime format using either asp or a Stored procedure that I can call durring my sql statement or if someone has a better idea lay it on me. I have never used stored procedures before so treat me like I am five and hold my hand here.
SQL Query help   (119 Views)
, i need help with sql I have 4 tables, UserTab(Id, Name, Email, Phone) ItemTab(ItemId, Type, Item) relationTab(Id, TransactionId, ItemId, Quantity, ReturnedDate, ReceiverId) loanTab(Id, TransId, BorrowerId, DateBorrowed, IssuerId, ReceiverId) I wanna do a search for employee and return the items tht the employee borrowed. Whats wrong with my sql statement SELECT UserTab.Name, ItemTab.Item FROM LoanTab INNER JOIN UserTab ON LoanTab.ReceiverId = UserTab.Id INNER JOIN relationTab ON LoanTab.TransId = relationTab.TransactionId INNER JOIN ItemTab ON relationTab.ItemId = ItemTab.ItemId WHERE Name LIKE '%strName%' I tried doing this in the query analyzer it displayed the fields but no entries.. Pls help,
Statement help   (103 Views)
Need a little help with this. Here is the statement I am using now: select * from fileload inner join gmpartsmaster on fileload.partnum = gmpartsmaster.partnum where dealercode = '510571-03' However, the data I want to see is what is left over in fileload.partnum, not the data I am actually bringing back with the statement.
Please help with Access SQL   (98 Views)
I VERY new at all of this. I am trying to get access to send an automated email when a combo box is changed to a specific status. The email part is working. However, I am wanting to send an email to the sales rep. that is listed (and only that rep.) on that particular form (which changes often). How do I get their email address to post Below is the code I currently have (the red area is the part I need help with) Any help would be wonderful!!
mySQL saving help   (266 Views)
, Im using mySQL 4.0.17. I have a piece of JDBC code that sends querys to the mySQL server to create a table add values to the tables etc. My problem is saving this information to a file so that when the sql server is disconnected or computer is restarted a txt file or something can be loaded to get me back to where i was when the restart happened. There are a few sites i have found that talk about saving, but most of them are talking about mySQL and PHP. Im just using mySQL not PHP or access. can anyone help
Strange error deleting a record from mdb table, help.   (246 Views)
Originally posted by : Salvador Gallego ( all, I found problems deleting a Row from an MDB database, this is my datagrid (is just the same i been using): ---> "CommandName" added ------------------ And here's the procedure which doesn't work to delete a row: ------------------ Sub DBAddDataGrid_Delete(Sender As Object, E As DataGridCommandEventArgs) ' ' Dim DeleteCmd As String = "DELETE from tbdownloads where IdF = @Id" objCommand.Parameters.Add(New OleDbParameter("@Id", OleDbType.VarChar, 11)) objCommand.Parameters("@Id").Value = DBAddDataGrid.DataKeys(CInt(E.Item.ItemIndex)) objCommand = New OleDbCommand (DeleteCmd, objConnection) objConnection.Open() objCommand.ExecuteNonQuery objConnection.Close() ShowDataGrid() End Sub ------------------ The Idea is that I render a field called Id which I use in the Sql query to compare with my autonumber field called IdF and then if it's the same, delete that row... But, of course, it doesn't work, the error I get is:----Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: Line 24: Dim DeleteCmd As String = "DELETE from tbdownloads where IdF = @Id"Line 25: Line 26: objCommand.Parameters.Add(New OleDbParameter("@Id", OleDbType.VarChar, 11)) Line 27: objCommand.Parameters("@Id").Value = DBAddDataGrid.DataKeys(CInt(E.Item.ItemIndex))Line 28: objCommand = New OleDbCommand (DeleteCmd, objConnection) ---- Why Any Ideas
help   (199 Views)
Please if someone can help me with this question I would really appreciate it: Write a SQL query to show the names and salary of salespeople who have two or more orders. First use a join query and then write the query again using a sub query. SALESPERSON: name, percent_of_quota, salary ORDER: number, cust_name, salesperson_name, amount CUSTOMER: name, city, industry_type
ASP/Access Recordset.Addnew help   (124 Views)
Originally posted by : Errol ( anyone tell me what's wrong with this portion of my code. It's my 2nd or 3rd day using asp and I can't seem to get it right. I'm getting an error page can't be displayed when my code hits these lines and I believe it has to do with the .addnew method. RS_SearchExistingUserId = "Select * From UserInfo Where UserId='" & Session("Session_UserID") & "' " Set RS = Server.CreateObject("ADODB.Recordset") RS.CursorType = adOpenDynamic RS.CursorLocation = adUseClient RS.Open RS_SearchExistingUserId, Application("Application_DBConn") If RS.EOF then RS.AddNew RS("UserId") = Session("Session_UserID") RS("UserPwd") = Session("Session_UserPwd") RS("FirstName") = Session("Session_FirstName") RS("LastName") = Session("Session_LastName") RS("EmailAddress") = Session("Session_EmailAddress") RS.Update RS.Close Response.Redirect("/index.asp") Else Session("Session_ErrorUserId_Taken") = True Response.Redirect("login.asp") End i
Sub Query help   (125 Views)
I have a table of hockey results containing the following info: HomePlayer, HomeScore, AwayPlayer, AwayScore and another table containing my Players. I'm trying to return all players along with the games they've played, the goals they've scored and the goals they've conceded. I've got the following SQL working for one specified player: Code: SELECT qHomeResults.HomePlayer AS PlayerID, qHomeResults.HomePlayed + qAwayResults.AwayPlayed AS GamesPlayed, qHomeResults.HomeScored + qAwayResults.AwayScored AS GoalsScored, qHomeResults.HomeConceded + qAwayResults.AwayConceded AS GoalsConceded FROM ( SELECT HomePlayer, Count(HomeScore) As HomePlayed, Sum(HomeScore) As HomeScored, Sum(AwayScore) As HomeConceded FROM Results WHERE Season = 6 AND HomePlayer = 1 GROUP BY HomePlayer ) AS qHomeResults INNER JOIN ( SELECT AwayPlayer, Count(AwayScore) As AwayPlayed, Sum(AwayScore) As AwayScored, Sum(HomeScore) As AwayConceded FROM Results WHERE Season = 6 AND AwayPlayer = 1 GROUP BY AwayPlayer ) AS qAwayResults ON qHomeResults.HomePlayer = qAwayResults.AwayPlayer It returns back the number of goals scored and conceded by a certain player (in the example I've used PlayerID 1), as such: Code: PlayerID GamesPlayed GoalsScored GoalsConceded -------------------------------------------------------- 1 16 80 51 That's fine. But I want to run this query for each of the players in my Players table. So it would look more like this: Code: PlayerID GamesPlayed GoalsScored GoalsConceded -------------------------------------------------------- 1 16 80 51 2 14 57 58 3 14 48 62 4 16 34 90 I know it's simply using the above working query as a sub query to a select on the Players table, but I can't get it right. The PlayerID from the Players table would need to be used for HomePlayer in the first sub query, and AwayPlayer in the second sub query. Hopefully that makes sense.
Sql help!!   (126 Views)
Hi Guys! I have three tables with the following structure: TABLE: COVER POLICY COVER DEFFECDATE DNULLDATE GP_ID 600001 1 30/03/2010 30/06/2010 6830 600001 62 30/03/2010 30/06/2010 8175 600001 1 30/06/2010 NULL 6872 TABLE: PREMIUM POLICY EFFECDATE NRECEIPT SOFFICIALBILL PREMIUM 600001 30/03/2010 1 IN100001 100 600001 30/04/2010 2 IN100002 100 600001 30/05/2010 3 IN100003 100 600001 30/06/2010 4 IN100004 50 600001 30/07/2010 5 IN100005 50 TABLE: PREMIUM_DETAIL NRECEIPT NDETCODE PREMIUM 1 1 75 1 62 25 2 1 75 2 62 25 3 1 75 3 62 25 4 1 50 5 1 50 I'd like to get the following resultset: POLICY COVER EFFECTDATE SOFFICIALBILL PREMIUM GP_ID 600001 1 30/03/2010 IN100001 75 6830 600001 62 30/03/2010 IN100001 25 8175 600001 1 30/04/2010 IN100002 75 6830 600001 62 30/04/2010 IN100002 25 8175 600001 1 30/05/2010 IN100003 75 6830 600001 62 30/05/2010 IN100003 25 8175 600001 1 30/06/2010 IN100004 50 6872 600001 1 30/07/2010 IN100005 50 6872
Sql query help/problem   (143 Views)
Hi all, hope you can help, I have a problem with an SQL command, and hope you can help me out. Kinda new to SQL so finding the answer difficult to find, but I think it's to do with an UPDATE statement (at a guess) I have a function that executes a stored procedure (spUpdateStoreDetails) that updates a table, but when i run the procedure only one of the two columns gets updated (fk_windowID). I need both the fk_window and fk_floorplans to get updated here is the query CREATE PROCEDURE [dbo].[spUpdateStoreDetails] @iStoreID DECIMAL ,@sOpensMonday VARCHAR(8) ,@sClosesMonday VARCHAR(8) ,@sOpensTuesday VARCHAR(8) ,@sClosesTuesday VARCHAR(8) ,@sOpensWednesday VARCHAR(8) ,@sClosesWednesday VARCHAR(8) ,@sOpensThursday VARCHAR(8) ,@sClosesThursday VARCHAR(8) ,@sOpensFriday VARCHAR(8) ,@sClosesFriday VARCHAR(8) ,@sOpensSaturday VARCHAR(8) ,@sClosesSaturday VARCHAR(8) ,@sOpensSunday VARCHAR(8) ,@sClosesSunday VARCHAR(8) ,@sTelNumber VARCHAR(50) ,@sFaxNumber VARCHAR(50) ,@sEmailAddress VARCHAR(250) ,@sSocialProfileAddress VARCHAR(250) ,@sPostalAddress VARCHAR(500) ,@iWindowID DECIMAL ,@ifloorID DECIMAL AS BEGIN SET NOCOUNT ON IF EXISTS (SELECT fk_storeID FROM tblStoreDetails WHERE fk_storeID = @iStoreID) BEGIN UPDATE tblStoreDetails SET OpensMonday = @sOpensMonday ,ClosesMonday = @sClosesMonday ,OpensTuesday = @sOpensTuesday ,ClosesTuesday = @sClosesTuesday ,OpensWednesday = @sOpensWednesday ,ClosesWednesday = @sClosesWednesday ,OpensThursday = @sOpensThursday ,ClosesThursday = @sClosesThursday ,OpensFriday = @sOpensFriday ,ClosesFriday = @sClosesFriday ,OpensSaturday = @sOpensSaturday ,ClosesSaturday = @sClosesSaturday ,OpensSunday = @sOpensSunday ,ClosesSunday = @sClosesSunday ,TelNumber = @sTelNumber ,FaxNumber = @sFaxNumber ,EmailAddress = @sEmailAddress ,SocialProfileAddress = @sSocialProfileAddress ,PostalAddress = @sPostalAddress ,fk_windowID = @iWindowID ,fk_floorplansID = @ifloorID WHERE fk_StoreID = @iStoreID END ELSE BEGIN INSERT INTO tblStoreDetails ( fk_StoreID ,OpensMonday ,ClosesMonday ,OpensTuesday ,ClosesTuesday ,OpensWednesday ,ClosesWednesday ,OpensThursday ,ClosesThursday ,OpensFriday ,ClosesFriday ,OpensSaturday ,ClosesSaturday ,OpensSunday ,ClosesSunday ,TelNumber ,FaxNumber ,EmailAddress ,SocialProfileAddress ,PostalAddress ,fk_windowID ,fk_floorplansID ) VALUES ( @iStoreID ,@sOpensMonday ,@sClosesMonday ,@sOpensTuesday ,@sClosesTuesday ,@sOpensWednesday ,@sClosesWednesday ,@sOpensThursday ,@sClosesThursday ,@sOpensFriday ,@sClosesFriday ,@sOpensSaturday ,@sClosesSaturday ,@sOpensSunday ,@sClosesSunday ,@sTelNumber ,@sFaxNumber ,@sEmailAddress ,@sSocialProfileAddress ,@sPostalAddress ,@iWindowID ,@ifloorID ) END END Please can someone have a look at this and tell me if there is a problem with this query, or could if it could be somehting else if you need more information please shout. kind regards MG
Need some help with a query asap please   (152 Views)
i have a temp table with data I want to insert records into the first table(tbl1) and use the ID field that is auto inc in tbl1 and insert some other data from tblTemp into tbl2 so i created a column to hold the identity from tbl1 in tblTemp named tbl1ID now I need to loop through the records inserting them and get the scope_identity of each record and insert that into the tblTemp.tbl1ID column help please how would I put this together Code: INSERT INTO tbl1 ( col1,col2 ) select col1,col2 FROM tblTemp and now i need to for each record INSERT INTO tblTemp SELECT @tbl1ID = SCOPE_IDENTITY() FROM tbl1
More SQL help   (126 Views)
I have an answers table, each row contains the results for a survey. One of the questions in the database is multiple choice, as in you can select more than one option, options are separated by commas when inserted in the database (Access), e.g. "1,2,4,6" I need to count the total number of options returned from this multiple choice question. So I need some SQL that will look through the data in a column called "Q8" and return how many answers have been given. I figured a good way to do this would be to count how many commas there are, and add the total number of commas onto the total numbers of times the survey has been taken. In the example above ("1,2,4,6") it would only return 3, when there are actually 4 options. If the survey has only been taken once, then adding 1 to 3 obviously equals 4. This should work never mind how many options were selected and never mind how many times the survey has been taken.... I hope So anyways, I know how to count the total number of times the survey has been taken, but how do I could how many times a comma appears in a column
Search   (207 Views)
i'm creating a website where i can search between 2 spesific dates which user will enter in the format of DD-MM-YYYY. the 2 dates will be inserted into 2 fields which is $input1 and $input2. heres my code: extract($_POST); //to set the date format //*************************** $input1 = date('DD-MM-YYYY h:i:s'); $input2 = date('DD-MM-YYYY h:i:s'); $sql= "select TITLE,MAGIC,TIMEREG from title_table WHERE MAGIC in ('X', 'Y', 'Z') AND TIMEREG >= to_date('$input1','DD-MM-YYYY HH24:MI:SS') AND TIMEREG